Skip to Content

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


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.

Add a comment
10|10000 characters needed characters exceeded

Related questions

0 Answers

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.