我正在尝试在 SAP GUI 中实现流程自动化。
我录制了一系列程序并将代码粘贴到宏表中。我使用以下命令让 Excel 读取 VBA 代码:
Dim SapGuiAuto As Object
Dim Application As Object
Dim Connection As Object
Dim Session As Object
Set SapGuiAuto = GetObject("SAPGUI")
Set Application = SapGuiAuto.GetScriptingEngine
Set Connection = Application.Children(0)
Set Session = Connection.Children(0)
对于 SAP 进行大量计算的其中一个部分,这需要几分钟的时间,在中间,Excel 会生成消息:
我必须单击“确定”才能继续,然后它会不停地弹出,我必须执行 10-15 次,这消除了自动化点。
在没有宏的情况下执行此操作时,SAP 不会给我任何错误。
我尝试将其关闭
Application.DisplayAlerts = False
它给了我:
我搜索了网络和网站,但几乎没有任何有用的信息,也许是因为我的问题太具体了。
一些附加信息:
我的 Excel 版本是 2013。
如何实现我能想到的三种解决方案之一:
- 禁用 OLE 弹出窗口
- 使其每次出现时自动单击“确定”
- 让 Excel 卡住并等待 SAP 执行其操作? (不知道这是否有意义。)尝试使用
Application.Wait
,但没有成功
最佳答案
上面的Storax实际上给出了另一个主题的链接以及问题的解决方案。
代码在这里:
Private Declare Function _
CoRegisterMessageFilter Lib "OLE32.DLL" _
(ByVal lFilterIn As Long, _
ByRef lPreviousFilter) As Long
Sub KillMessageFilter()
'''Original script Rob Bovey
'''https://groups.google.com/forum/?hl=en#!msg/microsoft.public.excel.programming/ct8NRT-o7rs/jawi42S8Ci0J
'''http://www.appspro.com/
Dim lMsgFilter As Long
''' Remove the message filter before calling Reflections.
CoRegisterMessageFilter 0&, lMsgFilter
''' Call your code here....
''' Restore the message filter after calling Reflections.
CoRegisterMessageFilter lMsgFilter, lMsgFilter
End Sub
关于excel - 如何处理等待另一个应用程序 (SAP GUI) 完成 OLE 操作的情况?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50142068/