AppleScript "macro" for Word fails under Lion

Have the following script I put together to help me quickly process texts for work (the reason is obscure and long-winded, but it is necessary for the work I do):

-- An AppleScript to remove formatting in paragraphs of text in Microsoft Word .docx files
-- Codes for the use of arrow keys (left, right, up, down):
--  * 28 for left
--  * 29 for right
--  * 30 for up
--  * 31 for down

tell application "System Events"
	tell application "Microsoft Word" to activate
	keystroke (ASCII character 30) using option down
	keystroke (ASCII character 31) using {option down, shift down}
	keystroke (ASCII character 28) using shift down
	keystroke "c" using command down
	-- The next step is only applicable
	-- if the free tool 'PlainClip' is installed
	-- do shell script "open -a 'Plain Clip'"
	keystroke "v" using command down
	keystroke "s" using command down
end tell

I recently had my MacBook Pro replaced because of multiple problems I was having, so am now running Lion. The problem I have with the above script is that when either pasted into an Automator process and assigned a keyboard shortcut or put in the Microsoft User Data/Word Script Menu Items and assigned a shortcut, it runs maybe once (often never) and then either brings up a “Save as” window or just does not carry out the formatting changes.

This was never a problem under Snow Leopard and I really need this functionality back.

It works fine if I manually select Word/Services/LevelText or the Script Menu/LevelText, it’s only when trying to use the assigned keyboard shortcuts that it falls down (and I have triple checked shortcut conflicts and have found none).

Can anyone please help?




Microsoft Word has a hugh AppleScript dictionary.
Could’t your task be done with “native” scripting?

Hi Stefan,

I tried that at first, but it was just too tedious. The script I put together does just exactly what I need.

But the short answer is that I downloaded Quicksilver and created a shortcut using that, so I guess that’s good enough.

It works at any rate.

Thanks all the same,