on 2023 Jun 09 7:45 AM
Can anyone help with looping issue on below.
Script run through first line on excel sheet and then stop.
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
REM ADDED BY EXCEL *************************************
Dim objExcel
Dim objSheet, intRow, i
Set objExcel = GetObject(,"Excel.Application")
Set objSheet = objExcel.ActiveWorkbook.ActiveSheet
For i = 2 to objSheet.UsedRange.Rows.Count
COL1 = Trim(CStr(objSheet.Cells(i, 1).Value)) 'Column1
COL2 = Trim(CStr(objSheet.Cells(i, 2).Value)) 'Column2
COL3 = Trim(CStr(objSheet.Cells(i, 3).Value)) 'Column3
COL4 = Trim(CStr(objSheet.Cells(i, 4).Value)) 'Column4
COL5 = Trim(CStr(objSheet.Cells(i, 5).Value)) 'Column5
REM ADDED BY EXCEL *************************************
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").expandNode "F00011"
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").selectedNode = "F00062"
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").topNode = "F00011"
session.findById("wnd[0]/usr/cntlIMAGE_CONTAINER/shellcont/shell/shellcont[0]/shell").doubleClickNode "F00062"
session.findById("wnd[0]/usr/ctxtRIMR0-MPOTY").setFocus
session.findById("wnd[0]/usr/ctxtRIMR0-MPOTY").caretPosition = 3
session.findById("wnd[0]").sendVKey 4
session.findById("wnd[1]/usr/sub/1[0,0]/sub/1/2[0,0]/sub/1/2/5[0,5]/lbl[1,5]").setFocus
session.findById("wnd[1]/usr/sub/1[0,0]/sub/1/2[0,0]/sub/1/2/5[0,5]/lbl[1,5]").caretPosition = 1
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/subMPOBJ:SAPLIMR4:7501/ctxtIFLOT-TPLNR").text = COL1
session.findById("wnd[0]/usr/ctxtIMPT-MPTYP").setFocus
session.findById("wnd[0]/usr/ctxtIMPT-MPTYP").caretPosition = 1
session.findById("wnd[0]").sendVKey 4
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/chkIMPT-INDCT").selected = true
session.findById("wnd[0]/usr/chkIMPT-INDCT").setFocus
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/chkIMPT-INDTR").selected = true
session.findById("wnd[0]/usr/txtIMPT-PSORT").text = "SMU"
session.findById("wnd[0]/usr/txtIMPT-PTTXT").text = COL2
session.findById("wnd[0]/usr/ctxtIMPT-ATNAM").text = "YPM_RUN_HRS"
session.findById("wnd[0]/usr/txtIMPT-DECIM").text = "2"
session.findById("wnd[0]/usr/ctxtIMPT-BEGRU").text = "4595"
session.findById("wnd[0]/usr/txtRIMR0-PYEAC").text = COL3
session.findById("wnd[0]/usr/txtRIMR0-ATEXT").text = COL4
session.findById("wnd[0]/usr/txtRIMR0-ATEXT").setFocus
session.findById("wnd[0]/usr/txtRIMR0-ATEXT").caretPosition = 5
session.findById("wnd[0]/usr/btnDETAIL").press
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]/usr/btnCREATE").press
session.findById("wnd[2]/usr/ctxtIMPH-TRANS").text = COL5
session.findById("wnd[2]/usr/ctxtIMPH-DATLO").text = "01.01.2018"
session.findById("wnd[2]/usr/ctxtIMPH-TIMLO").text = "07:00:00"
session.findById("wnd[2]/usr/ctxtIMPH-TIMLO").setFocus
session.findById("wnd[2]/usr/ctxtIMPH-TIMLO").caretPosition = 8
session.findById("wnd[2]/tbar[0]/btn[0]").press
session.findById("wnd[2]/tbar[0]/btn[0]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press
REM FINALIZATION CONTROL CHECK ************************
aux=col1 & " " & col2 & " " & col3 & " " & col4 & " " & col5
CreateObject("WScript.Shell").run("cmd /c @echo %date% %time% " & aux & " >> C:\SCRIPT\PlOrCreationLog.txt")
Next
msgbox "Process Completed"
REM FINALIZATION CONTROL CHECK ************************
Thanks Script Man, tried your script but still comes up wit an error "control could not be found by id".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
71 | |
11 | |
10 | |
10 | |
10 | |
8 | |
7 | |
7 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.