Need very simple script for Word to change table colors & borders

I’m sort of new to applescript and I’ve been trying for a long time to make a very simple script to change some elements of a selected table. All the samples I find seem to be to do more complicated things. Could someone please tell me how to make a simple script for just changing background color and border style of a selected table.


Hi Peter,

Personally, I don’t like the scripting dictionary for Microsoft Word (or any of the Office suite). The names they give things doesn’t flow well. The dictionary is also very convoluted. That aside…

This seems to do what you reqested.

tell application "Microsoft Word"
	activate -- so you can see it
	set background pattern color index of shading of selection to red
	set inside line style of border options of selection to line style dot
end tell

Best wishes

John M

Thanks for the help. One more question, I can’t figure out the syntax for changing the color to a specific RGB color instead of just a color name like “red”. Could you please tell me how to specify an RGB color.


One other question, I can’t for the life of me figure out how to change the width of the whole table (a table that is already selected) to say 5.5 inches.


Thanks, finally got my table formatting macro completely working.

Again, many thanks for your help.


Could you please post your entire AppleScript here. I would really like to know how you have managed to set the width of a selected table. I am also wondering why my script has weird results when setting the border thickness of a table border. See below:

tell application "Microsoft Word"
	set myRange to selection
	set line style of (get border selection which border border bottom) to line width225 point
	get line width of (get border selection which border border bottom)--results in line width75 point ??? what is going on here? Why is this not resulting in "line width225 point"

(*The Results from trial and error*)
	--width25 = fine dots
	--width225 = cornered sine wave
	--width50 = dashed line
	--width75 = dash + 3 dots + dash
	--width100 = 3 lines
	--width150 = 2 lines
	--width300 = single
	--width450 = does not work
	--width600 = does not work

end tell

I am using Microsoft Office 2011 Word version 14.2.3

Model: MacBook Air
Operating System: Mac OS X (10.7)