Re: excel question
Re: excel question
- Subject: Re: excel question
- From: Paul Berkowitz <email@hidden>
- Date: Sun, 06 Feb 2011 11:58:02 -0800
- Thread-topic: excel question
On 2/5/11 9:18 PM, "Ameen Ashraf" <email@hidden> wrote:
> How can we get or set the shading of a cell in Excel?
If you investigate the Excel dictionary's entry for 'cell' in the Table
Suite, you'll see that it includes a property 'interior object' of type
'interior'. If you click to check the properties of an 'interior', you'll
see that you can set or get its color, its pattern and its pattern color,
plus a few other properties. (I'd avoid 'color index' if I were you.)
'pattern' is a long list of constants representing all the various patterns
available in the UI.
*Note that for Microsoft Office apps - Excel, Word and PowerPoint - the
values for 'color', although the dictionary claims they are 'RGB color' are
different values than AppleScript's usual (own) values, which are based on a
0-65535 range, whereas for Microsoft colors, RGB is based on a 0-255 range.
(If you ever have to convert between the two, on set of values is the
square, or inverted the square root, rounded off, of the other's.)
So, to simply do one thing or another:
tell application "Microsoft Excel"
set pattern of interior object of cell "A4" to pattern gray 25
end tell
or
tell application "Microsoft Excel"
set color of interior object of cell "A4" to {200, 0, 0}
end tell
If you want to do both, or here set the color of the pattern instead of a
solid color:
tell application "Microsoft Excel"
tell interior object of cell "A4"
set pattern to pattern gray 25
set pattern color to {200, 0, 0}
end tell
end tell
--
Paul Berkowitz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden