我正在尝试在 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)
For one of the parts SAP makes a lot of calculations which takes a few minutes and around the middle of it, Excel generates the message:
我必须单击“确定”才能继续,然后它会不停地弹出,我必须执行 10-15 次,这消除了自动化点。
当没有宏的情况下执行此操作时,SAP 不会给我任何错误。
我尝试将其关闭
Application.DisplayAlerts = False
相反,它给了我:
我搜索了网络和网站,但几乎没有任何有用的信息,也许是因为我的问题太具体了。
一些附加信息:
- 我的笔记本电脑正在工作,未经许可我无法安装任何其他软件或更新。
- I tried checking the Excel option for DDE, but it only gives me an error when I try to run the script.
我的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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)