window name

Hi folks,
I’m trying to script Pages to export to .doc file via single command. It works in case I know the name of the window, but I would like to have it more generic. My code:


tell application process "Pages"
 click menu item "Export." of menu 1 of menu bar item "File" of menu bar 1
 click checkbox "Word" of radio group 1 of sheet 1 of window "Untitled"
 click button "Next..." of sheet 1 of window "Untitled"
end tell

What’s the trick to get name of the window? I did try several ways but none does work correctly


set myWindow to a reference to the first window

Thanks
Robert

Hi,

why not


tell application "Pages" to save front document as "SLDocumentTypeMSWord" in "path:to:word:document.doc"

Stefan,
thanks a bunch! I did spend 2 hours figuring my way of doing this. Can you expand your code to display Save dialog?

Thx


tell application "Pages" to save front document as "SLDocumentTypeMSWord" in (choose file name)