Search code examples
vbasap-gui

When using SAP GUI Scripting in VBA, how can I view SAP GUI objects properties while coding - like in IntelliSense?


Is there a way to view the properties on SAP GUI objects?

Like this:

Properties drop-down for Workbook object

But for SAP objects like the following ones:

Set SAPGuiAuto = GetObject("SAPGUI")
Set App = SAPGuiAuto.GetScriptingEngine
Set Connection = App.Children(0)
Set SAPSession = Connection.Children(0)

I ask this after reading the last part of the answer to this post: VBA general way for pulling data out of SAP

If however you want to use early binding so that your VBA editor might show the properties and methods of the objects you are using, you need to add a reference to sapfewse.ocx in the SAP GUI installation folder.


Solution

  • This is something so badly advertise by the SAP team, they should definitely do a better job there.

    Basically you first of all need to add a reference to the SAP object model, the libraries that VBA will understand. Don't know how familiar are you with there references to object models. Basically, on your VBA Editor, click Tools, then References, then Browse, and find this file: "C:\Program Files\SAP\FrontEnd\SAPgui\sapfewse.ocx" (or possibly "C:\Program Files (x86)\SAP\FrontEnd\SAPgui\sapfewse.ocx").

    Now you'll be able to browse it on the Object Explorer (press F2 in the VBE), and declare the types.

    You need now to familiarise yourself with the Types of this library. Some hints, they all start with Gui, like, GuiSession, GuiApplication, GuiConnection, GuiBlabla... Names are pretty explicit and intuitive.