2

我只是想关闭一个文档(不退出单词),但这不起作用。

我试过了 :

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 回答