Excel 设置会话=连接时出现对象必需错误。子级(0)
我正在尝试启动一个SAPGUI脚本,并更改VBA代码的一些变量 我明白了 需要运行时错误“424”对象 在Excel 设置会话=连接时出现对象必需错误。子级(0),excel,vba,sap-gui,Excel,Vba,Sap Gui,我正在尝试启动一个SAPGUI脚本,并更改VBA代码的一些变量 我明白了 需要运行时错误“424”对象 在Set session=Connection.Children(0) 您收到错误消息是因为对象连接不存在,只需将此对象更改为实际对象SAPCon,然后执行您的代码。我也面临同样的问题,通过改变这个目标,问题得到了解决: Set SapGuiAuto = GetObject("SAPGUI") 'Get the SAP GUI Scripting object Set SA
Set session=Connection.Children(0)
您收到错误消息是因为对象
连接
不存在,只需将此对象更改为实际对象SAPCon
,然后执行您的代码。我也面临同样的问题,通过改变这个目标,问题得到了解决:
Set SapGuiAuto = GetObject("SAPGUI") 'Get the SAP GUI Scripting object
Set SAPApp = SapGuiAuto.GetScriptingEngine 'Get the currently running SAP GUI
Set SAPCon = SAPApp.Children(0) 'Get the first system that is currently connected
Set session = SAPCon.Children(0) 'Get the first session (window) on that connection
最好的
Edgar M.如果在Edgar M的建议后仍然挂起问题(纠正
连接到SAPCon
),
尝试在设置会话之前添加一点延迟。。
(或悬挂发生在哪条线之前)
.. 因此,在这种情况下,SAPCon有足够的时间(在运行环境中)在代码继续之前完成(与更快地获取pc有关)。
就像:
在此之后,随机挂起似乎结束了。
最好,JanW在每个“设置XXX=
”之后添加:如果XXX什么都不是,那么msgbox“上面的东西坏了”
运行时错误“424”需要对象,VBA突出显示下面一行set session=Connection.Children(0)
Set SapGuiAuto = GetObject("SAPGUI") 'Get the SAP GUI Scripting object
Set SAPApp = SapGuiAuto.GetScriptingEngine 'Get the currently running SAP GUI
Set SAPCon = SAPApp.Children(0) 'Get the first system that is currently connected
Set session = SAPCon.Children(0) 'Get the first session (window) on that connection
..
Set SAPCon = SAPApp.Children(0)
WScript.Sleep 200
Set session = SAPCon.Children(0)