cancel
Showing results for 
Search instead for 
Did you mean: 

Trying SAP GUI SCRIPTING in VBA but Excel can't find session. What's causing this?

0 Kudos

Hello,

I am wanting to automate some stuff in SAP through VBA. For now, I am trying to execute the following code:

  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

The last line is resulting in a error: "Run-time error '614'". I placed SAPCon in the watch window but it has a count of 0 for sessions. Despite SAP Easy Access being open in the background. The rest of the lines execute fine.

Also, GUI scripting is enabled on my local computer but not the server. But, I looked at the documentation and it said I can still scripts, just not record them. If this is what's causing the issues then I wonder if I can use SAP's ActiveX libraries instead? I have no way of getting GUI scripting enabled on the server side.

Any help is appreciated.

Accepted Solutions (0)

Answers (0)