Object Required: ' ActiveWorksheet" -

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.

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]
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,214,965
Messages
6,122,496
Members
449,089
Latest member
Raviguru

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top