I have been using an AppleScript to process text in a MS Word 2008 file, and then save as a text file. I have upgraded my computer so now I am using newer Mac OS Sierra 10.12.3 and newer MS Word 15.30 and cannot get this part of the AppleScript to work properly on my new iMac.
===============================
tell application “Microsoft Word”
activate
save as the active document file name path of the active document & “.txt” file format format dostext
end tell
=============================
On the old system, this command would save the currently opened MS Word file to the same directory and name as the original plus add “.txt” to the end.
Now when I run this on my new iMac, the file is saved one directory up with the name “Documents.txt”
I am not sure I have posted this in the correct area. I have tried several searches and have not found this answer.
Thank you for your help.
I found that the problem was with the “path” part of the command. For some reason the newer Mac OS or MS Word did not like the “path” command–so I replaced it with the hard coded path name. I know this is not the best way, but at least it works now, and I documented this in my AppleScript.
May you try to run:
tell application "Microsoft Word"
activate
set activePath to path of the active document
log activePath
log "point 1"
log (get class of activePath) # is it a file object or a text one ?
log "point 2"
set destPath to activePath & ".txt" # correct if activePath is a path
log destPath
log "point 3"
set destPath to (activePath as text) & ".txt" # required if activePath is a text object
log destPath
log "point 4"
save as the active document file name destPath file format format dostext
end tell
Yvan KOENIG running Sierra 10.12.3 in French (VALLAURIS, France) mercredi 15 février 2017 17:49:29