MacOS Automator + Applescript解决方案,可将docx导出为pdf [英] MacOS Automator + Applescript solution for exporting docx to pdf

查看:74
本文介绍了MacOS Automator + Applescript解决方案,可将docx导出为pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读了许多不同的线程并尝试了一堆脚本之后,我还是挠了挠头,但似乎没有用.

Scratching my head after reading lots of different threads on this and tried a bunch of scripts but none seem to work.

我想使用Automator来自动将Word 2016中的一系列docx文件转换为pdf.

I'd like to use Automator to automate Word 2016 conversion of a selection of docx files to pdf.


使用了以下Automator服务:


Used the following Automator Service:


使用了以下脚本:


Used the following script:

on run {input, parameters}
    tell application id "com.microsoft.Word"
        activate
        open input
        set doc to name of active window
        set theOutputPath to (input & ".pdf")
        save as active document file name theOutputPath file format format PDF
    end tell
end run


导致错误: Microsoft Word出现错误:活动文档不理解另存为"消息.

推荐答案

主要问题是 input

The main issue is that input is a list. You have to use a repeat loop to process each file separately

我添加了一行以在转换后关闭当前文档

I added a line to close the current document after having been converted

on run {input, parameters}
    tell application id "com.microsoft.Word"
        activate
        repeat with aFile in input
            open aFile
            set theOutputPath to ((aFile as text) & ".pdf")
            tell active document
                save as it file name theOutputPath file format format PDF
                close saving no
            end tell
        end repeat
    end tell
end run

这篇关于MacOS Automator + Applescript解决方案,可将docx导出为pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆