When recording an SAP GUI Script, the first lines of the code are always the same:
If Not IsObject(app) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set app = SapGuiAuto.GetScriptingEngine
End If
If Not IsObject(Connection) Then
Set Connection = app.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 app, "on"
End If
In this code, four variables are used: app, SapGuiAuto, Connection and session. Why can these variables be used without having been declared? I have made countless scripts based on this, and everything has always worked. I do not like the feeling of not understanding my own code, though. :-)
Option Explicitis not set.Sub, and it will connect to your SAP like a good boy.