Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I was using the colorindex of the palette in my vba code (2003) but it's not convenient because it gives different colors when the vba code is used on excel workbooks with a different palette I though i would get the same color whatever the palette by using RGB codes instead but i have the same problem : For example, RGB (204, 255, 204) gives different colors in different workbooks How can i get always the same colors? Thanks |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The only way would be to configure the colours of every workbook as it was
opened. Excel will map any colour that you define to the closest match on the standard color palette and use that colorindex. -- __________________________________ HTH Bob "thomas" <nomail wrote in message ... Hello, I was using the colorindex of the palette in my vba code (2003) but it's not convenient because it gives different colors when the vba code is used on excel workbooks with a different palette I though i would get the same color whatever the palette by using RGB codes instead but i have the same problem : For example, RGB (204, 255, 204) gives different colors in different workbooks How can i get always the same colors? Thanks |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The palette only contains 56 colours, in a default palette there are 10
duplicates. If you attempt to apply your own RGB Excel will match it to the closest it can find in the palette. Your particular RGB example does exist in a default palette, so if index 35 has not been customized you will get a perfect match. If you want to be sure your colour is applied, but only customize a palette colour if necessary you could do something like this colVal = RGB(234, 255, 234) ' very pale green With Range("a1").Interior .Color = colVal If .Color < colVal Then ' the RGB doesn't exist ActiveWorkbook.Colors(25) = colVal .ColorIndex = 25 End If End With Of course you'd need to be sure you are not messing with someones carefully customized colour. Regards, Peter T "thomas" <nomail wrote in message ... Hello, I was using the colorindex of the palette in my vba code (2003) but it's not convenient because it gives different colors when the vba code is used on excel workbooks with a different palette I though i would get the same color whatever the palette by using RGB codes instead but i have the same problem : For example, RGB (204, 255, 204) gives different colors in different workbooks How can i get always the same colors? Thanks |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Not necessarily "useless to use RGB codes" at all, depends on the overall
scenario. Sometimes RGB values are exactly what you do want to use. Regards, Peter T "thomas" <nomail wrote in message ... so it's useless to use RGB codes. better keeping using colorindex ? "thomas" <nomail a écrit dans le message de groupe de discussion : ... Many thanks I now better understand "Peter T" <peter_t@discussions a écrit dans le message de groupe de discussion : ... The palette only contains 56 colours, in a default palette there are 10 duplicates. If you attempt to apply your own RGB Excel will match it to the closest it can find in the palette. Your particular RGB example does exist in a default palette, so if index 35 has not been customized you will get a perfect match. If you want to be sure your colour is applied, but only customize a palette colour if necessary you could do something like this colVal = RGB(234, 255, 234) ' very pale green With Range("a1").Interior .Color = colVal If .Color < colVal Then ' the RGB doesn't exist ActiveWorkbook.Colors(25) = colVal .ColorIndex = 25 End If End With Of course you'd need to be sure you are not messing with someones carefully customized colour. Regards, Peter T "thomas" <nomail wrote in message ... Hello, I was using the colorindex of the palette in my vba code (2003) but it's not convenient because it gives different colors when the vba code is used on excel workbooks with a different palette I though i would get the same color whatever the palette by using RGB codes instead but i have the same problem : For example, RGB (204, 255, 204) gives different colors in different workbooks How can i get always the same colors? Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Entering ASCII codes with Excel 2003 | Excel Discussion (Misc queries) | |||
Excel 2003 list of field codes for footers? | Excel Discussion (Misc queries) | |||
Can't format cell color/text color in Office Excel 2003 in files . | Excel Discussion (Misc queries) | |||
Using excel 2003 cannot see Canadian Postal Codes | Excel Worksheet Functions | |||
Excel 2003 will not display color fonts or color fill cells | Excel Worksheet Functions |