4

私はここでおかしくなります。「アクティブなドキュメントファイル形式のPDFとして保存」の無数の順列/バリエーションを試しましたが、どれも機能しないようです。それらすべてでAppleScriptエラーが発生します。

だから誰もが私に言うことができます:

Wordを使用してアクティブなドキュメントをAppleScriptでPDFファイルとして保存するための正確な構文は何ですか?

Office for Macスクリプトには一貫性がまったくないようです。これは、ExcelとPowerPointで機能しており、構文が異なるためです。

優れている

save active workbook in 'MyFile.pdf' as PDF file format

パワーポイント

save active presentation in 'MyFile.pdf' as save as PDF

Wordの正しい構文は何ですか?

ありがとう!

4

2 に答える 2

3

結局私はそれを見つけたようです:

set myDoc to "/Users/X/Desktop/test.docx"
set pdfSavePath to "Users:X:Desktop:test.pdf"

tell application "Microsoft Word"
        activate
        open myDoc
        set theActiveDoc to the active document
        save as theActiveDoc file format format PDF file name pdfSavePath
    end tell

私はAppleScriptの専門家ではありません。パスの区切り文字として、:の代わりにスラッシュを使用しました。で:それは動作します

于 2012-04-06T13:33:36.857 に答える
0

Joris Mansスクリプトは非常に優れていますが、欠陥があります。Wordにアクティブなドキュメントの準備ができていることを保証するものではありません(set theActiveDoc to the active document欠落した値を返す可能性があります)

また、Finderの選択を入力として使用するようにスクリプトを改善し、PDFを単語ファイルと同じ場所に配置しました。私はファイルタイプをテストしませんでしたが、wordはそれについて文句を言います。

tell application "Finder"
    set input to selection
end tell

tell application id "com.microsoft.Word"
    activate
    repeat with aFile in input
        open aFile
        set theOutputPath to ((aFile as text) & ".pdf")
        repeat while not (active document is not missing value)
            delay 0.5
        end repeat
        set activeDoc to active document
        save as activeDoc file name theOutputPath file format format PDF
        close active document saving no
    end repeat
end tell
于 2019-06-22T13:49:03.100 に答える