Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel Reports Wrong Border Color

In VBA, this code

ActiveCell.Borders(xlEdgeBottom).Color

returns the original pallette color rather than the custom
color the user set that pallette color to be. The
spreadsheet displays the desired custom border color but
the code returns only the original color.

Saving/closing the workbook/Excel does not affect the
problem.

How do you get the actual displayed color of a border
line? BTW, the environment is XL97.

Tx
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Excel Reports Wrong Border Color

Returning .Color of a cell colour format gives the Long
value of the ColorIndex used for the format, ie 1 of the
56 workbook palette colours.

If you apply .Color as a format (rather than a
Colorindex), if Excel cannot find an exact match in the
current palette it will apply what it calculates is the
closest colour match from the palette.

Thus returning .Color may not be the same as the .Color
that was applied, or rather what was attempted to be
applied. In other words your code is correctly returning
the colour, which may or may not be not be what was
applied.

If you want to customize a colour then do so direct to the
palette, then apply the ColorIndex as the format. Maybe
this will demonstrate what's going on:

Sub Test()
'2nd time comment next line
ActiveWorkbook.ResetColors 'default palette
mycolor = RGB(240, 20, 120)
Cells(1, 2) = mycolor

Cells(2, 1).Interior.Color = mycolor
Cells(2, 2) = Cells(2, 1).Interior.Color
Cells(2, 3) = Cells(2, 1).Interior.ColorIndex

ActiveWorkbook.Colors(6) = mycolor
Cells(3, 1).Interior.ColorIndex = 6
Cells(3, 2) = Cells(3, 1).Interior.Color
Cells(3, 3) = Cells(3, 1).Interior.ColorIndex
End Sub

Regards,
Sandy

PS
This is new - now MS's newsreader is automatically giving
me an an anonymous address. Perhaps just as well as in the
last 4 weeks I've been bombarded by several Mb/day of spam
purporting to originate from MS.
savituk yahoo co uk

-----Original Message-----
In VBA, this code

ActiveCell.Borders(xlEdgeBottom).Color

returns the original pallette color rather than the

custom
color the user set that pallette color to be. The
spreadsheet displays the desired custom border color but
the code returns only the original color.

Saving/closing the workbook/Excel does not affect the
problem.

How do you get the actual displayed color of a border
line? BTW, the environment is XL97.

Tx
.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I change the default border color in Excel? Steve W Setting up and Configuration of Excel 3 April 3rd 23 07:27 PM
How to change the default Border, Font Color, and Cell Color Elijah Excel Discussion (Misc queries) 3 November 2nd 05 11:52 PM
Default Border, Font Color, and Cell Background Color Elijah Excel Discussion (Misc queries) 1 October 28th 05 04:10 PM
HOW DO I CHANGE THE AUTOMATIC BORDER COLOR IN EXCEL? mhbento Excel Worksheet Functions 1 March 16th 05 04:55 PM
error checking reports a value in the formula is of the wrong dat. [email protected] Excel Worksheet Functions 2 November 7th 04 07:25 PM


All times are GMT +1. The time now is 04:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"