on 03-27-2017 8:27 AM
Hi ,
I am trying to play the .vbs script for VA42, but getting an error as
Please find my code below:
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
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
session.findById("wnd[0]/tbar[0]/okcd").text = "/nva42"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtVBAK-VBELN").text = COL1
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4426/subSUBSCREEN_TC:SAPMV45A:4908/tblSAPMV45ATCTRL_U_ERF_KONTRAKT/txtVBAP-ARKTX[4,0]").setFocus
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_OVERVIEW/tabpT\01/ssubSUBSCREEN_BODY:SAPMV45A:4426/subSUBSCREEN_TC:SAPMV45A:4908/tblSAPMV45ATCTRL_U_ERF_KONTRAKT/txtVBAP-ARKTX[4,0]").caretPosition = 10
session.findById("wnd[0]").sendVKey 2
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP_ITEM/tabpT\06").select
session.findById("wnd[0]/usr/tabsTAXI_TABSTRIP/tabpT\06/ssubSUBSCREEN_BODY:SAPLV60F:4201/ctxtFPLA-LODAT").text = COL2
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/tbar[0]/btn[3]").press
session.findById("wnd[0]/tbar[0]/btn[11]").press
aux=col1 & ” ” & col2
CreateObject(“WScript.Shell”).run(“cmd /c @echo %date% %time% ” & aux & ” >> C:\SCRIPT\PlOrCreationLog.txt”)
next
msgbox “Process Completed”
Hello Rajesh,
as far as I can see you use
Set objExcel = GetObject(,”Excel.Application”)
instead of
Set objExcel = GetObject(,"Excel.Application")
The double quotes are not correct.
Also the comment signs, for example here
COL1 = Trim(CStr(objSheet.Cells(i, 1).Value)) ‘Column1
instead of
COL1 = Trim(CStr(objSheet.Cells(i, 1).Value)) 'Column1
Replace all these characters in your code and it should run without invalid character error.
I try it on my system and it works with the changes above.
Let us know your result.
Cheers
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Great! Thank you very much!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you very much, you just solved my problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
9 | |
9 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.