如何在 MS Word 的 AppleScript 中使用 "save as" 命令
How to use "save as" command in AppleScript with MS Word
我想使用 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
版本
- macOS 莫哈韦沙漠 10.14.4
- Microsoft Word Mac 16.27 (19071500)
- 脚本编辑器 2.11 (203.1),Apple 脚本 2.7
使用 PowerPoint
下面的代码有效。成功保存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
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
我想使用 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
版本
- macOS 莫哈韦沙漠 10.14.4
- Microsoft Word Mac 16.27 (19071500)
- 脚本编辑器 2.11 (203.1),Apple 脚本 2.7
使用 PowerPoint
下面的代码有效。成功保存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
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