So I am trying to pull data from SAP using excel macros. I am new to VBA so please bear with me. I found a topic on here called VBA pulling data from SAP for dummies and I am confused. What I am trying to do is as follows:
Here is the link VBA pulling data from SAP for dummies
I can't seem to get by Set session = connection.Children(0) 'Get the first session (window) on that connection.
Any help is much appreciated. The reason I am doing this is because SAP wont export longtext and it takes an act of God to get it fixed.
This is what i use for all my connections for SAP:
'Connect to SAP to run automation.
If Not IsObject(SAP_applic) Then
Set SapGuiAuto = GetObject("SAPGUI")
Set SAP_applic = SapGuiAuto.GetScriptingEngine
End If
Set connection = SAP_applic.Children(0)
If Not IsObject(connection) Then
Set connection = application.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