AppleScript: set cell background color of Microsoft Excel

Using AppleScript, how can I change the background color of "cells from A3 to E3" to light gray?

I still want the font to be black.

+2


source to share


1 answer


Two caveats with this answer: you didn't mention which version of Excel and the following was tested in version 2004.

tell application "Microsoft Excel"
    set theRange to range "A3:E3"
    set interiorObject to interior object of theRange
    set color index of interiorObject to 5 -- '5' is only a dummy value; change as needed.
end tell

      



In the dictionary, color index

there is "a color specified as an index value in the current color palette". In other words, the color index that is light gray in your setup may differ elsewhere.

+2


source







All Articles