Excel VBA:检测由使用RunBatch运行的其他应用程序提供的错误消息

时间:2015-04-23 13:07:58

标签: excel vba error-handling

我从Excel-VBA脚本调用批处理文件:

strCmdLine = "C:\temp\RunReporter.bat"
lngTaskID = Shell(strCmdLine, vbNormalFocus)
Call RunBatch(lngTaskID)

批处理文件又触发另一个应用程序(某个供应商)。此应用程序有时会给出错误消息(对话框)。 有人需要单击“确定”,以便应用程序关闭,然后句柄返回到VBA。

我希望创建一个脚本来检测错误消息并“点击”“确定,以便VBA脚本继续完成这项工作。

1 个答案:

答案 0 :(得分:0)

我使用AutoIt开发了一个应用程序(可执行文件)。应用程序以无限循环运行,查找错误消息,如果找到,则关闭窗口。

'some code
'shell the AutoIT application. 
'more code
'kill the shell AutoIt application