【发布时间】:2014-11-05 00:47:53
【问题描述】:
我有一个控制 Microsoft Excel 的小程序。我需要与系统事件交谈以单击一些对话框按钮。现在,在升级(原文如此)到 Yosemite 之后,脚本在两个错误之间交替出现(!!):
- “系统事件出错:连接无效。”数字 -609,光标在“打开 wbfile”
- '无法打开文档“tst”。系统事件无法打开“Microsoft Excel 97-2004 工作表格式”的文件。此错误在对话框中给出,之后单击“确定”可使脚本成功完成。
不知何故,在“告诉进程“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
【问题讨论】:
标签: excel applescript