我只是试图关闭一个文档(没有退出单词),但这不起作用。
我试过了:
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
答案 0 :(得分:1)
关闭活动文档并关闭文档1都适合我。也许在分配theActiveDoc变量之前需要一个延迟语句?