Saturday, June 30, 2012

How to find and fill a color in Excel Cell

Set xlObj=getobject("","Excel.Application")
Set xlWBObj=xlObj.workbooks.open("c:\delete.xls")
set xlWSObj=xlWBObj.worksheets(1)
xlWSObj.cells(1,1).Font.Color=vbRed  'This statement changes the color of the Text in the specified cell
xlWSObj.cells(2,1).Interior.ColorIndex=4 'This method changes the color of the background of the cell
print  xlWSObj.cells(1,1).Font.Color
print xlWSObj.cells(2,1).Interior.ColorIndex
xlWBObj.save
xlWBObj.close
xlObj.application.quit
Set xlObj=nothing

No comments: