Skip to Content
avatar image
Former Member

Create new SAP session with VBA from Excel

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"

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers