我想使用AppleScript将MS Word文档(docx)转换为PDF。
我使用脚本编辑器尝试了以下代码。 (MS Word文档已预先打开。)
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
,失败并显示错误:
The active document doesn't understand "save as" message.
number -1708 from active document
以下代码有效。它已成功将test.pdf
保存在~/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
答案 0 :(得分:0)
outpath
仍然无效,并且必须是HFS路径
set outpath to (path to documents folder as text) & "test.pdf"
tell application "Microsoft Word"
activate
set activeDoc to active document
save as activeDoc file name outpath file format format PDF
end tell