简体   繁体   English

与 SAP 建立连接的问题

[英]Issue establishing connection with SAP

I am trying to establish connection using SAP GUI from Excel VBA and keep getting the same 424 error.我正在尝试使用 Excel VBA 中的 SAP GUI 建立连接并不断收到相同的 424 错误。

Runtime Error 424 “Object Required”运行时错误 424 “需要对象”

I've tried multiple ways changing variables but nothing seems to be working for me:(我尝试了多种更改变量的方法,但似乎没有什么对我有用:(

在此处输入图像描述

截屏

If Not IsObject(Application) Then
   Set SapGuiAuto = GetObject("SAPGUI")
   Set Applicationa = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
   Set Connection = Applicationa.Children(0)
End If
If Not IsObject(session) Then
   Set session = Connection.Children(0)
End If
If IsObject(WScript) Then
   WScript.ConnectObject session, "on"
   WScript.ConnectObject Application, "on"
End If
session.findById("wnd[0]").resizeWorkingPane 131, 25, False
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "F00006"

I guess the SAP GUI Scripting Engine is not activated on the client or server side, you can use this way to localize the problem:我猜SAP GUI Scripting Engine 没有在客户端或服务器端激活,您可以使用这种方式来定位问题:

On Error Resume Next ' note that you will need to check errors mannualy

'check SAPGUI is running
Dim guiSAP As Object: Set guiSAP = GetObject("SAPGUI")
    
If guiSAP Is Nothing Then
    MsgBox ("SAPGUI is not running!"), vbCritical, "SAP GUI"
    Exit Sub
End If

'check that scripting engine is activated
Dim appSAP As Object: Set appSAP = guiSAP.GetScriptingEngine

If appSAP Is Nothing Then
    MsgBox ("SAP GUI Engine is not activated!"), vbCritical, "SAP GUI Scripting"
    Exit Sub
End If

'check connection to SAP
Dim connectionSAP As Object: Set connectionSAP = appSAP.Children(0)

If connectionSAP Is Nothing Then
    MsgBox ("SAP connection lost!"), vbCritical, "SAP Connection"
    Exit Sub
End If

'check SAP session
Dim sessionSAP As Object: Set sessionSAP = connectionSAP.Children(0)

If sessionSAP Is Nothing Then
    MsgBox ("No Active SAP Session!"), vbCritical, "SAP Session"
    Exit Sub
End If

CONTACT ME i will solve this on anydesk联系我我会在anydesk上解决这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM