Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 设置会话=连接时出现对象必需错误。子级(0)_Excel_Vba_Sap Gui - Fatal编程技术网

Excel 设置会话=连接时出现对象必需错误。子级(0)

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

我正在尝试启动一个SAPGUI脚本,并更改VBA代码的一些变量

我明白了

需要运行时错误“424”对象

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)