Henkvdm
New Member
- Joined
- Apr 16, 2018
- Messages
- 1
My issue:
The Script I use worked perfectly until now. The last time I ran it was last month "March 2018". The script itself is very simple.
I open an Excel Workbook ( only one), execute the script from SAP SCM.
The script reads one MARKET at a time and then runs trough a list of steps.
The problem is this, suddenly it doesn't seem to be able to get the Workbook.
Any ideas?
The code is in Blue below.
The Script I use worked perfectly until now. The last time I ran it was last month "March 2018". The script itself is very simple.
I open an Excel Workbook ( only one), execute the script from SAP SCM.
The script reads one MARKET at a time and then runs trough a list of steps.
The problem is this, suddenly it doesn't seem to be able to get the Workbook.
Any ideas?
The code is in Blue below.
Code:
[COLOR=#000080]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[/COLOR]
[COLOR=#000080]REM ADDED BY EXCEL *************************************[/COLOR]
[COLOR=#000080]Dim objExcel
Dim objSheet, intRow, i
Set objExcel = GetObject(,"Excel.Application")
Set objSheet = objExcel.ActiveWorkbook.ActiveSheet[/COLOR]
[COLOR=#000080]For i = 2 to objSheet.UsedRange.Rows.Count
COL1 = Trim(CStr(objSheet.Cells(i, 1).Value)) 'Column1[/COLOR]
[COLOR=#000080]
REM ADDED BY EXCEL *************************************[/COLOR]
[COLOR=#000080]session.findById("wnd[0]/tbar[0]/okcd").text = "/nYVCERF"
session.findById("wnd[0]").sendVKey 0
session.findById("wnd[0]/usr/ctxtP_MARKET").text = COL1
session.findById("wnd[0]/usr/ctxtP_MARKET").caretPosition = 3
session.findById("wnd[0]/tbar[1]/btn[8]").press
session.findById("wnd[0]/tbar[0]/btn[0]").press
session.findById("wnd[0]/tbar[0]/btn[11]").press
session.findById("wnd[0]/tbar[0]/btn[3]").press[/COLOR]
[COLOR=#000080]REM FINALIZATION CONTROL CHECK ************************ [/COLOR]
[COLOR=#000080]aux=col1 & " " & col2 & " " & col3 & " " & col4 & " " & col5 & " " & col6
CreateObject("WScript.Shell").run("cmd /c [MENTION=13910]Echo[/MENTION] %USERNAME% %date% %time% " & aux & " >> C:\APO_SCRIPTS\YVCERF_Log.txt")
next
msgbox "Process Completed"[/COLOR]
[COLOR=#000080]REM FINALIZATION CONTROL CHECK ************************[/COLOR]