【发布时间】:2017-03-20 11:48:09
【问题描述】:
我正在尝试使用 AppleScript 自动转换 MS PowerPoint(版本 15.30)2016 文件。我有以下脚本:
on savePowerPointAsPDF(documentPath, PDFPath)
tell application "Microsoft PowerPoint"
open alias documentPath
tell active presentation
delay 1
save in PDFPath as save as PDF
end tell
quit
end tell
end savePowerPointAsPDF
savePowerPointAsPDF("Macintosh HD:Users:xx:Dropbox:zz yy:file.pptx", "Macintosh HD:Users:xx:Dropbox:zz yy:file.pdf")
这个脚本工作正常,除了:
- 第一次运行时,出现“授予访问权限”对话框。
- 我每次运行它时,都会出现一个对话框,上面写着: "文件名已被移动或删除。"
单击所有这些对话框后,它就可以正常工作了。我曾尝试使用 POSIX 文件名,但没有成功。我找不到一条有空格的路径。
以下内容与 Excel 一起解决了第一个问题,但似乎不适用于 PowerPoint:
set tFile to (POSIX path of documentPath) as POSIX file
总之,我只是尝试使用 AppleScript 来使用 PowerPoint 2016 for Mac 打开一个 PowerPoint 文件。路径和文件名可能包含空格和其他 macOS 允许的非字母数字字符。
关于如何解决这些问题有什么建议吗?
【问题讨论】: