I’m trying to create a simple loop for below code:
If Not IsObject(application) Then
Set SapGuiAuto = GetObject("SAPGUI")
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]").maximize
session.findById("wnd[0]/titl/shellcont/shell").pressContextButton "%GOS_TOOLBOX"
session.findById("wnd[1]/usr/tblSAPLSWUGOBJECT_CONTROL").getAbsoluteRow(1).selected = true
session.findById("wnd[1]/usr/tblSAPLSWUGOBJECT_CONTROL/txtSWLOBJTDYN-DESCRIPT[0,1]").setFocus
session.findById("wnd[1]/usr/tblSAPLSWUGOBJECT_CONTROL/txtSWLOBJTDYN-DESCRIPT[0,1]").caretPosition = 0
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/titl/shellcont/shell").selectContextMenuItem "%GOS_PCATTA_CREA"
session.findById("wnd[1]/usr/ctxtDY_PATH").text = "C:UsersdamczDesktop"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").text = "6 Gearbox and Gear Oil System - 4 Yr V110.pdf"
session.findById("wnd[1]/usr/ctxtDY_FILENAME").caretPosition = 48
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[11]").press
This should repeat multiple times until reach the last line of SAP order.
Also need to set variables for path and filename. In macro users should be able to define both values, two separate cells in excel which will be copied as a path and file name.
Didn’t try anything yet, don’t have skills to do it 🙂
Daniel Zatwarnicki is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.