Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 3rd, 2003, 02:17 PM
hbcontract hbcontract is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 59 hbcontract User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 36 sec
Reputation Power: 6
Changing color in the entire header in Excel via VB?

Hi, I have an excel sheet with header row. Is it anyway to change the hearder background color?? I know we can change the font color via VB using '.Rows(1).Font.ColorIndex = 5' ... but i can't seem find anything to change the background color. Please help. Or is it any side with references about this issue?

Reply With Quote
  #2  
Old October 3rd, 2003, 02:29 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,178 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 56 m 45 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
hey HB- I forgot to tell you earlier. When you're looping through fields in your Excel file, you can do this too...

for inti = 1 to rsrecordset.fields.count
xlapp.cells (1,inti) = cstr(rsrecordset.fields(inti))
xlapp.cells (1,inti).interior.color = rgb(0,0,0)
next inti


That will set the first row in the sheet as a header for as many fields as you have in the recordset, with black background. You could also include something like this

xlapp.cells(1,inti).font.color = rgb(255,255,255)
xlapp.cells(1,inti).border.color = rgb(0,0,0)
xlapp.cells(1,inti).font.bold

which will set the font color to white, the cell border color to black, and bold the text in the cell.

Good Luck!
__________________
Fisherman

"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein

Reply With Quote
  #3  
Old October 3rd, 2003, 03:51 PM
hbcontract hbcontract is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 59 hbcontract User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 36 sec
Reputation Power: 6
Thanks, FM ... but where can i find the color code?

Reply With Quote
  #4  
Old October 3rd, 2003, 04:02 PM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,178 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 9 h 56 m 45 sec
Reputation Power: 111
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
what color code are you wanting to use? If you're not familiar with rgb coding, then here's a brief explanation. The RGB Function of visual basic uses the combination of values representing the amounts of red, green, and blue, respectively, to create the color you want. The values range from 0 to 255, and are designated by rgb(R,G,B). Some examples would be...

RGB(0,0,0) = BLACK because a lack of color is the definition of black

RGB(255,255,255) = White, because a light source that includes all colors is white

RGB(180,180,180) = Medium Gray

RGB(255,0,0) = Red

RGB(0,255,0) = Green

RGB(0,0,255) = Blue...


And you can mix and match combinations to create a color...

RGB(255,0,255) = Purple (red + blue)
RGB(0,255,255) = Aqua/BlueGreen... and so on.

So.. let me ask you, what color are you trying to create? If you google search for RGB color values, you can probably come across an HTML developer's site to give you the values for the color you're looking for. I actually have an ASP page that process all combinations of RGB (to a point, theres an awfully lot of them), and sets them into the background of cells in a table to display them. If you have IIS on your machine, I can send it to you and you can run it to find the color you want.

Reply With Quote
  #5  
Old October 3rd, 2003, 04:09 PM
hbcontract hbcontract is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 59 hbcontract User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 36 sec
Reputation Power: 6
Thank you very much, FM ... I actually want Grey But from what you discribed how the color works, I actaully learned a lot Thanks again, FM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Changing color in the entire header in Excel via VB?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT