Answered Excel 2003 Cell Background Color

ggunter

Well-known member
Joined
Apr 23, 2008
Messages
137
Programming Experience
Beginner
I am trying to create an Excel "class" that will provide basic functions such as opening a workbook, formatting cells, etc.

Does anyone know how to change the background/foreground colors of a cell in Excel 2003? In VB6 this was such a simple thing to do. But I have just spent 4 hours searching MSDN, the web, and the Interop.Excel Object Browser and I can't find it anywhere.:confused:

Please! Any help would be greatly appreciated
 
Last edited:
Guess I was making it more complicated than it was. Anyway, here is the answer I came up with.:p

VB.NET:
Public Sub CellBackColor(ByVal strCell As String, ByVal DesiredColor As Object)

        'select range
        xlsRange = xlsApp.Range(strCell)

        'set color
        xlsRange.Interior.ColorIndex = DesiredColor

End Sub

BTW, "DesiredColor" cannot be "Color.Black". It has to be the numerical color index. At least, it threw an error when I tried it.
 
Back
Top