PDA

View Full Version : Excel 2007 Color Compatibility Issue



Sowanso
10-02-2008, 02:33 AM
Dear Community,

I am trying to bypass the Excel 2007 color backward compatibility issue. In case you have not experienced the issue yet it is very well described here (http://dearmicrosoftofficeteam.blogspot.com/2008/03/dear-microsoft-office-2007-team-please_03.html).

I thought that I might be able to take the Interior.color value for each cell, reset cells settings and then set back the color by its exact specification as can be seen in the code below.

Sub RGBColors()
Dim lngRed As Long
Dim lngGreen As Long
Dim lngBlue As Long
Dim lngDummy As Long
Dim Cell As Range

For Each Cell In Selection

With Cell.Interior
lngDummy = .Color
If lngDummy <> 16777215 Then
lngRed = lngDummy Mod 256
lngDummy = (lngDummy - lngRed) / 256
lngGreen = lngDummy Mod 256
lngBlue = (lngDummy - lngGreen) / 256
.Pattern = xlNone
.Color = RGB(lngRed, lngGreen, lngBlue)
End If
End With

Next

End Sub
I used decomposition to RGB colors for tweaking purposes. However while setting the cell.interior.color in Excel 2007 it automatically assigns cell.interior.ColorIndex property to the nearest color. When opening the file in Excel 2003 it does not load interior.color (as I would expect) but it seems to load the ColorIndex which is skewed.

Does anyone have any idea how to deal with this issue? It became very annoying and forcing my clients into installation of Excel 2007 is unfortunately not an option.