MacでAutomatorを使って自動的にWordファイルをPDFに変換する

Automatorを使う。スクリプトはApple Communityの次のページを参考にした。 https://discussions.apple.com/thread/250654441

1. Automatorで新規アクション「ワークフロー」を開く

2. 「選択されたFinder項目を取得」と 「AppleScriptを実行」を右側でつなげる

スクリーンショット 2020-06-01 11.21.14

3. 「AppleScriptを実行」に以下のコードを入れる。

use scripting additions

on run {input, parameters}
repeat with aFile in input
       tell application "System Events"
           set inputFile to disk item (aFile as text)
           set outputFileName to (((name of inputFile) as text) & ".pdf")
       end tell

       tell application id "com.microsoft.Word"
           activate
           open aFile
           tell active document
               save as it file name outputFileName file format format PDF
               close saving no
           end tell
           set defaultPath to get default file path file path type documents path
       end tell

       tell application "System Events"
           set outputPath to (container of inputFile)
           set outputFile to disk item outputFileName of folder defaultPath
           move outputFile to outputPath
       end tell
   end repeat
   return input
end run

4. FinderでWordファイル (.doc/.docx) を選択しておく。

5. Automatorで「実行」する。

6. 待つ。

7. できる。

この記事が気に入ったらサポートをしてみませんか?