I need to get values from an existing Excel sheet and transfer them t SAP GUI. This is done by an vbscript and works. But I need to get a loop this is where I am struggeling.
The loop should start from the second line.
The code below is not entering the values into SAP GUI.
Can someone please give an advice?
Thanks in advance.
Dim arrExcelValues()
i = 7
x = 0
Do Until objExcel.Cells(i,"N").Value = ""
ReDim Preserve arrExcelValues(x)
arrExcelValues(x) = objExcel.Cells(i, "N").Value
i = i + 1
x = x + 1
Loop
For Each werk in arrExcelValues
session.findById("wnd[0]/tbar[0]/okcd").text = "mm01"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtRMMG1-MATNR").text = (objSheet.Cells(46,"F").Value)
session.findById("wnd[0]/usr/ctxtRMMG1_REF-MATNR").text = (objSheet.Cells(46,"F").Value)
session.findById("wnd[0]/usr/ctxtRMMG1_REF-MATNR").setFocus
session.findById("wnd[0]/usr/ctxtRMMG1_REF-MATNR").caretPosition = 8
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[1]").sendVKey 0
' ************************************* here comes the problem
session.findById("wnd[1]/usr/ctxtRMMG1-WERKS").text = (objSheet.Cells(werk,"N").Value)
session.findById("wnd[1]/usr/ctxtRMMG1-VKORG").text = (objSheet.Cells(werk,"O").Value)
' ************************************* "erstes" Werk
session.findById("wnd[1]/usr/ctxtRMMG1_REF-WERKS").text = (objSheet.Cells(6,"N").Value)
session.findById("wnd[1]/usr/ctxtRMMG1_REF-VKORG").text = (objSheet.Cells(6,"O").Value)
session.findById("wnd[1]/usr/ctxtRMMG1-VKORG").setFocus
session.findById("wnd[1]/usr/ctxtRMMG1-VKORG").caretPosition = 4
session.findById("wnd[1]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[0]").press
' ************************************* here comes the problem
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP06/ssubTABFRA1:SAPLMGMM:2000/subSUB5:SAPLZMM_GINCOFIELDS:5802/ctxtMARC-PRCTR").text = (objSheet.Cells(werk,"P") & (objSheet.Cells(38,"P")).Value)
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP06/ssubTABFRA1:SAPLMGMM:2000/subSUB5:SAPLZMM_GINCOFIELDS:5802/ctxtMARC-PRCTR").setFocus
session.findById("wnd[0]/usr/tabsTABSPR1/tabpSP06/ssubTABFRA1:SAPLMGMM:2000/subSUB5:SAPLZMM_GINCOFIELDS:5802/ctxtMARC-PRCTR").caretPosition = 6
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[1]/usr/btnSPOP-OPTION1").press
session.findById("wnd[0]/tbar[0]/btn[15]").press
Next