I want to convert MS Word document (docx) to PDF with AppleScript.
I tried the code below with Script Editor. (MS Word document is opened beforehand.)
tell application "Microsoft Word"
activate
set outpath to "Documents/test.pdf"
set activeDoc to active document
save as activeDoc file name outpath file format format PDF
end tell
and failed with the error:
The active document doesn't understand "save as" message.
number -1708 from active document
Versions
- macOS Mojave 10.14.4
- Microsoft Word for Mac 16.27 (19071500)
- Script Editor 2.11 (203.1), Apple Script 2.7
With PowerPoint
The code below worked. It successfully saved test.pdf
under ~/Library/Containers/com.microsoft.Powerpoint/Data/Documents
.
set outpath to "Documents/test.pdf"
tell application "Microsoft PowerPoint"
activate
save active presentation in outpath as save as PDF
end tell