Hi,
I am using below vba code to exctract data from SAP to excel.
In this case vba code insert parameters to SAP transaction code selection (e.g. 20070203) and execute/export report.
Is it possible to creat vba code which will copy parameters from excel and past it in t-code instead of now determined value 20070203?
For example from excel sheet cell in row 1, column A. Which part of code has to be updated and how?
Thank you for your help!!
I am using below vba code to exctract data from SAP to excel.
In this case vba code insert parameters to SAP transaction code selection (e.g. 20070203) and execute/export report.
Is it possible to creat vba code which will copy parameters from excel and past it in t-code instead of now determined value 20070203?
For example from excel sheet cell in row 1, column A. Which part of code has to be updated and how?
Thank you for your help!!
VBA Code:
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUISERVER")
Set application = SapGuiAuto.GetScriptingEngine
End If
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
session.findById("wnd[0]").resizeWorkingPane 270,33,false
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtSD_SAKNR-LOW").text = "20070203" - "VALUE TO BE COPIED FROM EXCEL"!
session.findById("wnd[0]/usr/ctxtSD_BUKRS-LOW").text = "AT06"
session.findById("wnd[0]/usr/ctxtSD_SAKNR-LOW").caretPosition = 8
session.findById("wnd[1]/usr/subSUBSCREEN:SAPLSPRI:0600/cmbPRIPAR_DYN-PRIMM").setFocus
session.findById("wnd[1]/usr/subSUBSCREEN:SAPLSPRI:0600/cmbPRIPAR_DYN-PRIMM").key = ""
session.findById("wnd[1]/tbar[0]/btn[13]").press
session.findById("wnd[1]/usr/btnSOFORT_PUSH").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/tbar[0]/btn[11]").press
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtBTCH2170-FROM_DATE").text = "01.01.2020"
session.findById("wnd[0]/usr/ctxtBTCH2170-TO_DATE").text = "31.12.2999"
Application.Wait (Now + TimeValue("0:00:10"))
session.findById("wnd[0]/usr/ctxtBTCH2170-TO_DATE").setFocus
session.findById("wnd[0]/usr/ctxtBTCH2170-TO_DATE").caretPosition = 10
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]").sendVKey 8
session.findById("wnd[0]/usr/lbl[136,10]").setFocus
session.findById("wnd[0]/usr/lbl[136,10]").caretPosition = 5
session.findById("wnd[0]").sendVKey 2
session.findById("wnd[0]/usr/lbl[147,10]").setFocus
session.findById("wnd[0]/usr/lbl[147,10]").caretPosition = 3
session.findById("wnd[0]").sendVKey 2
session.findById("wnd[0]").sendVKey 40
session.findById("wnd[0]/usr/chk[1,12]").selected = true
session.findById("wnd[0]/usr/chk[1,12]").setFocus
session.findById("wnd[0]").sendVKey 44
session.findById("wnd[0]/usr/chk[1,3]").selected = true
session.findById("wnd[0]/usr/lbl[21,3]").setFocus
session.findById("wnd[0]/usr/lbl[21,3]").caretPosition = 0
session.findById("wnd[0]").sendVKey 2
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").select
session.findById("wnd[1]/usr/subSUBSCREEN_STEPLOOP:SAPLSPO5:0150/sub:SAPLSPO5:0150/radSPOPLI-SELFLAG[1,0]").setFocus
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/ctxtDY_PATH").text = "C:\..."
session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "TEST_AT06_2.xls"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 9
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[15]").press<br>