我需要定期从word文件生成PDF文件,而且我已经厌倦了用手做文件。让我的苹果脚本在当前目录中处理指定的文件?
手动操作,我所做的只是打开一个文件,然后单击“另存为PDF”。所以,有人会认为applescript会是一个很好的方法来做到这一点。 [如果你有另一种方法比applescript,我打开它]
我快到了,下面的脚本工作,除了完整的路径是硬编码。
tell application "Microsoft Word"
open file "Macintosh HD:Users:me:repos:training:class:Activities:ActivityGuide.docx"
set doc to document "ActivityGuide.docx"
save as doc file name "Macintosh HD:Users:me:repos:training:class:Activities:ActivityGuide.pdf" file format format PDF
end tell
我需要它在其他机器上为其他人工作,所以路径的用户名和其他部分可能会改变。如果我可以从脚本的当前目录中执行此操作,我将被设置。
我发现这一点:Applescript to launch file from current folder?
tell application "Finder"
open file "somefile.txt" of folder of (file (path to me))
end tell
这对于从Word中的当前目录中打开一个应用程序,通过查找工作,但我想我需要用“的Microsoft Word”的应用程序中打开它,如果我将使用“另存为”。但是,如果将“Finder”的应用程序更改为“Microsoft Word”,则此方法无法使用。
欢迎任何建议。 [编辑:清晰度]
精美的作品。谢谢您的帮助! – ThoughtfulHacking 2012-04-22 23:17:13