2

Word を終了せずにドキュメントを閉じようとしているだけですが、うまくいきません。

私はもう試した :

close documents saving no
close active document
close document 1

しかし、これはどれも機能していません..

私が得るエラー(クローズラインで)は次のとおりです。

Microsoft Word got an error: The object you are trying to access does not exist

これは単純化されたスクリプトです。誰にもアイデアはありますか?オンラインのすべての例はこの構文を使用しているようですが、Mac Office 2011 バージョンで何かが変更されたかどうかわかりませんか?

set input to {POSIX path of "/Users/Wesley/Desktop/test.doc"}


--ENABLE GUI SCRIPTING
tell application "System Events"
if UI elements enabled is false then set UI elements enabled to true
end tell

--RUN THE GUISCRIPT
set pdfSavePath to POSIX path of (choose folder with prompt "Set destination folder")
repeat with x in input
display dialog x

tell application "Microsoft Word"
    activate
    open x
    set theActiveDoc to the active document

    close theActiveDoc saving no

    return
    end tell
 end repeat
4

1 に答える 1

1

アクティブなドキュメントを閉じる と ドキュメント 1 を閉じる の両方が機能します。おそらく、theActiveDoc 変数が割り当てられる前に遅延ステートメントが必要ですか?

于 2013-01-23T12:41:55.443 に答える