Hey community! Thank you in advance for your help.
I have the following script:
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
msgbox "Proccessing, this may take a few second"
REM ADDED BY EXCEL *************************************
Dim objExcel
Dim objSheet, intRow, i
Set xclapp = CreateObject("Excel.Application")
Set xclwbk = xclapp.Workbooks.Open("\\ILBEVXENFILER01.OneScope.net\frdprofile\GBasso2\Documents\sapAutoNew\TEST2.xlsx")
set xclsht = xclwbk.Sheets("Sheet1")
For i = 2 to xclsht.UsedRange.Rows.Count
COL1 = Trim(CStr(xclsht.Cells(i, 1).Value)) 'Column1
COL2 = Trim(CStr(xclsht.Cells(i, 2).Value)) 'Column2
COL3 = Trim(CStr(xclsht.Cells(i, 3).Value)) 'Column3
COL4 = Trim(CStr(xclsht.Cells(i, 4).Value)) 'Column4
REM ADDED BY EXCEL *************************************
session.findById("wnd[0]/shellcont/shellcont/shell/shellcont[0]/shell/shellcont[0]/shell").pressButton "OPEN"
session.findById("wnd[1]/usr/ctxtCNPB_W_ADD_OBJ_DYN-PROJ_EXT").text = COL1
session.findById("wnd[1]/usr/ctxtCNPB_W_ADD_OBJ_DYN-PROJ_EXT").caretPosition = 9
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[1]/btn[13]").press
session.findById("wnd[0]/shellcont/shellcont/shell/shellcont[0]/shell/shellcont[1]/shell").selectedNode = "000002"
session.findById("wnd[0]/tbar[1]/btn[23]").press
session.findById("wnd[1]").sendVKey 4
session.findById("wnd[2]/usr/lbl[1,4]").setFocus
session.findById("wnd[2]/usr/lbl[1,4]").caretPosition = 1
session.findById("wnd[2]").sendVKey 2
session.findById("wnd[1]/tbar[0]/btn[8]").press
session.findById("wnd[0]/shellcont/shell/shellcont[0]/shell/shellcont[1]/shell[1]").selectedNode = " 2"
session.findById("wnd[0]/usr/subSC_MAIN_FOR_CONTAINER:SAPLCK_ECP_GUI:0500/cntlCONTAINER_MAIN_500/shellcont/shell/shellcont[0]/shell").sapEvent "","","SAPEVENT:GET_MODEL"
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/usr/subSC_MAIN_FOR_CONTAINER:SAPLCK_ECP_GUI:0500/cntlCONTAINER_MAIN_500/shellcont/shell/shellcont[0]/shell").sapEvent " ","CK_ECP_F4_HANDLER=&ZPS101="&COL3&"&ZPS100=&ZPS130=10&ZPS131=1&ZPS102=1&ZPS103=1&ZPS106="&COL3&"&ZPS107="&COL4&"&ZPS117=&ZPS108=&ZPS209=&ZPS109="&COL2&"&CK_ECP_F4_HANDLER=&ZPS000=1010&ZPS113=1&ZPS110=1&ZPS120=99&ZPS111=1&ZPS210=10&ZPS104=5&ZPS105=5&ZPS300=1&ck_ecp_edit=","SAPEVENT:SUBMIT"
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/shellcont/shellcont/shell/shellcont[1]/shell/shellcont[1]/shell").topNode = " 23"
REM FINALIZATION CONTROL CHECK ************************
aux=col1 & " " & col2 & " " & col3 & " " & col4
CreateObject("WScript.Shell").run("cmd /c @echo %date% %time% " & aux & " >> C:\SCRIPT\PlOrCreationLog.txt")
next
msgbox "Process Completed"
REM FINALIZATION CONTROL CHECK ************************<br>
is there away to do everything until getting to:
session.findById("wnd[1]").sendVKey 4
then check if it is possible to execute this command. if it is, continue doing the rest of the code as it is. else do:
session.findById("wnd[0]/usr/subSC_MAIN_FOR_CONTAINER:SAPLCK_ECP_GUI:0500/cntlCONTAINER_MAIN_500/shellcont/shell/shellcont[0]/shell").sapEvent " ","CK_ECP_F4_HANDLER=&ZPS101="&COL3&"&ZPS100=&ZPS130=10&ZPS131=1&ZPS102=1&ZPS103=1&ZPS106="&COL3&"&ZPS107="&COL4&"&ZPS117=&ZPS108=&ZPS209=&ZPS109="&COL2&"&CK_ECP_F4_HANDLER=&ZPS000=1010&ZPS113=1&ZPS110=1&ZPS120=99&ZPS111=1&ZPS210=10&ZPS104=5&ZPS105=5&ZPS300=1&ck_ecp_edit=","SAPEVENT:SUBMIT"
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/shellcont/shellcont/shell/shellcont[1]/shell/shellcont[1]/shell").topNode = " 23"