简体   繁体   中英

Issue establishing connection with SAP

I am trying to establish connection using SAP GUI from Excel VBA and keep getting the same 424 error.

Runtime Error 424 “Object Required”

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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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