pages 09 and applescript, save current file as .doc and overwrite current file

1.2k views Asked by At

I want to save current opened file as .doc overwriting the current file.. so I have to find the current opened document path, then save the current file on the same path, saving as .doc

Anyone can help? I've tried in many ways but always failed... (I'm on OSX 10.6 with pages 09)

thanks

1

There are 1 answers

0
Philip Regan On

Give this a whirl:

tell application "Pages" to tell document 1
   set oldname to name
   set oldPath to get path
   try
       set docPath to oldPath
   on error
       set oldPath to (path to documents folder as text) & oldname & ".pages"
       save in oldPath
   end try
   tell application "System Events" to set oldPath to path of disk item oldPath
   if oldPath ends with ":" then set oldPath to text 1 thru -2 of oldPath (* useful is the app saves as packages *)
   set docPath to text 1 thru -(1 + (count of "Pages")) of oldPath & "doc"
   save as "Microsoft Word 97 - 2004 document" in docPath
end tell

Source: MacScripter, so you may need to fiddle with it a bit.