Re: Setting cell styles
Re: Setting cell styles
- Subject: Re: Setting cell styles
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 16 Nov 2012 12:39:03 -0800
- Thread-topic: Setting cell styles
Title: Re: Setting cell styles
On 11/16/12 9:50 AM, "Jeremy Roussak" <email@hidden> wrote:
Is there an easy way to set all the cells in a particular column of a table to the same style? I know I can loop, and this works:
tell active document
set mytable to table 1
set myttr to Word style "ttr"
end tell
set rowCount to count mytable's rows
repeat with i from 1 to rowCount
set txt to text object of (get cell from table mytable row i column 2)
set txt's style to myttr
end repeat
but it doesn't look nice.
If you check the Word dictionary, you'll see in the Table Suite that 'table' itself has a 'style' property. Its class is described as 'base style', but in fact it works to set the style to a Word style too. So whether are you referring to a table style here, or to a regular paragraph style, either way it works just to set the style of the table.
tell application "Microsoft Word"
tell active document
set mytable to table 1
set myttr to Word style "Table Colorful 3"
-- or : set myttr to Word style "Emphasis"
end tell
set style of mytable to myttr
end tell
It's instantaneous.
I also tried it with both paragraph and table styles I created myself, and it works. (You have to have created the styles in the particular document, since styles are elements of 'document' and not of the Word application; but you probably know that already. If this is a style you'll want again in other documents, add it to your Normal template or make a special template to which you add this style. Then any new document you make (always, if added to Normal, or from the appropriate template otherwise) will have the style built in.
--
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