2013-01-23 67 views
2

我只是试图关闭一个文件(没有退出单词),但这是行不通的。Applescript:关闭Word文档? (Office 2011)

我已经试过:

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

我会试着用tell语句中的重复例程(在activate语句之后)。可能会有影响。 – 2013-01-23 13:10:05

+0

@DigiMonk我已经完全删除了重复,没有效果。谢谢。 – Wesley

回答

1

关闭活动文档和关闭文档1都适用于我。也许你需要一个延迟语句,然后分配ActiveDoc变量?

+0

刚刚尝试过(增加了5秒的延迟,但没有区别)。你使用的是哪个版本的办公室? (家庭/学生/专业版) – Wesley

+0

2011 14.2.5您是否尝试过自行运行结算报表? – adayzdone

+0

刚刚更新到同一版本,但没有更改。这在一个新的imac上。通过自己运行近似声明,你的意思是什么?我确实需要先打开一个文档,不是吗? – Wesley

相关问题