我有一个控制Microsoft Excel的AppleScript。我需要与System Events对话,点击一些对话框按钮。现在,在升级(原文如此)到Yosemite之后,脚本在两个错误之间交替出现(!!):
不知何故,打开一个工作簿,告诉进程" Microsoft Excel"'不管用。 我可以在“告诉应用程序" Microsoft Excel"”中打开工作簿。很好,但随后 我无法按下对话框按钮。
任何帮助表示赞赏!!!
set wbfile to "/private/tmp/tst.xls"
tell application "Microsoft Excel"
activate
end tell
delay 0.1
tell application "System Events"
delay 0.1
tell process "Microsoft Excel"
delay 0.1
set foo to open wbfile
try
set cancel to button "Cancel" of window 1
click (cancel)
end try
try
set macros to button "Enable Macros" of window 1
click macros
end try
try
set links to button "Ignore Links" of window 1
click links
end try
end tell
end tell
set dat to "flflfl"
set output to (dat as string)
return output
答案 0 :(得分:0)
您可以使用ignoring application responses
并让Excel打开文件而无需等待应用程序的反馈。该脚本将立即进入后续步骤。
之后,系统事件可以单击按钮:
set wbfile to "/private/tmp/tst.xls"
ignoring application responses
tell application "Microsoft Excel"
activate
set foo to open wbfile
end tell
end ignoring
delay 1
tell application "System Events"
tell process "Microsoft Excel"
try
set cancel to button "Cancel" of window 1
click (cancel)
end try
try
set macros to button "Enable Macros" of window 1
click macros
end try
try
set links to button "Ignore Links" of window 1
click links
end try
end tell
end tell
问候,迈克尔/汉堡