【问题标题】:How to convert excel sheet to pdf automatically using applescript?如何使用applescript自动将excel表格转换为pdf?
【发布时间】:2020-07-02 02:59:20
【问题描述】:

我是 Mac 新手,对 Applescript 一无所知。我尝试了一些之前讨论过的参考Applescript Excel 2016 save as PDF,但我不是关于一些关键字/语法,例如 documentPath、PDFPath、documentPath 的 POSIX 路径等。 我的文件路径是“Macintosh HD:Users:sa:documents:folder_1”,我的 excel 文件名是 dataworld.xls。我想将我的工作簿的第一张表转换为 pdf,并且 pdf 应该在与文件路径相同的位置生成。 有人可以帮帮我吗?

【问题讨论】:

    标签: excel macos applescript


    【解决方案1】:

    简单的解决方案,选择工作表并运行脚本:

    set destinationFolder to (path to documents folder as text) & "folder_1:"
    tell application "Microsoft Excel"
        save as active sheet filename (destinationFolder & "dataworld.pdf") file format PDF file format
    end tell
    

    【讨论】:

    • 所以我应该将路径作为“Macintosh HD:Users:sa:documents:folder_1”代替“folder_1:”还是将excel文件名与路径一起放置?
    • (path to documents folder as text) & "folder_1:"表示相对路径,与"Macintosh HD:Users:sa:documents:folder_1"相同
    • 将destinationFolder设置为“Macintosh HD:Users:sa:documents:folder_1”,我可以省略(文本文件夹的路径)和“folder_1:”对吗?
    • 强烈建议始终使用相对路径以使脚本可移植。
    • 好的,明白了。谢谢
    猜你喜欢
    • 2016-07-16
    • 2019-11-26
    • 2013-10-05
    • 2019-11-03
    • 2021-05-30
    • 2017-02-13
    • 2016-06-22
    • 2017-03-21
    • 1970-01-01
    相关资源
    最近更新 更多