Skip to Content

Create new SAP session with VBA from Excel

Feb 01, 2017 at 08:36 AM


avatar image
Former Member

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[1]/usr/txtV-LOW").Text = "BE51_PTW/MD"

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers