cancel
Showing results for 
Search instead for 
Did you mean: 

Create new SAP session with VBA from Excel

former_member308954
Discoverer
0 Kudos

I have a VBA-script in Excel to download data from SAP. Everything works fine, but when it's launched it always takes an existing SAP-session to run the script (even if another transaction was open in that session). So, I'd like to first open an new SAP-session to run the script there, but haven't found a solution yet.

Here's the beginning of my current script:

Sub ExportSAP()
Set SapGuiAuto = GetObject("SAPGUI")
Set SAPApp = SapGuiAuto.GetScriptingEngine
Set SAPCon = SAPApp.Children(0)
Set session = SAPCon.Children(0)

session.StartTransaction "CADO"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[1]/btn[17]").press
session.findById("wnd[1]/usr/txtV-LOW").Text = "BE51_PTW/MD"

Accepted Solutions (0)

Answers (0)