Save as Word via script
I am trying to write an AppleScript that will save a Pages document as a Word document (with the same file name), a script I can execute with a single keystroke (assigned by FastScripts). I found such a script in an archived 2010 entry in this forum (reproduced below), using the GUI interface, but it does not work. The AppleScript dictionary for Pages has no entry for "sheet", so the script fails. I am using Pages 09 Version 4.0.5.
Another thread mentioned an Automator workflow someone had written to do this, but the link to it gets a "Not found" page error. And I cannot see any Pages actions in Automator. Does anyone know how this can be done?
Here's the script that does not work (this script--if it worked--would save the Word doc with the name "Pages document" every time; I'd want to modify that to use the name of the Pages file):
--BEGINNING OF SCRIPT
set theName to "Pages document.doc"
tell application "Pages" to activate
tell application "System Events" to tell process "Pages"
click menu item "Export…" of menu 1 of menu bar item "File" of menu bar 1
repeat until sheet 1 of window 1 exists
delay 1
end repeat
click radio button "Word" of radio group 1 of sheet 1 of window 1
click button "Next…" of sheet 1 of window 1
keystroke "a" using command down -- Select All (⌘A)
keystroke theName
keystroke "d" using command down -- save to Desktop (⌘D)
keystroke return
end tell
--END OF SCRIPT
Pages 09-OTHER, Mac OS X (10.6.7)