I have a few macros in excel that work properly when I run them in excel manually, but when I set up a script in VBScript, Excel gives me an error message and the macros go unexecuted. Does anyone know why this is happening and what can be done to fix it? The command below "Windows("icecleared_oiloptions.xlsx").Activate" is where excel pointed out that needs debugging.
Sub Save_Close_TN()
'
' Save_Close_TN Macro
'
Windows("icecleared_oiloptions.xlsx").Activate
ActiveWorkbook.Save
ActiveWindow.Close
End Sub
The below code is the call function for the VBS:
Dim objExcel, xlBook
Set objExcel = CreateObject("Excel.Application")
Set xlBook = objExcel.Workbooks.Open("Q:\GAS\Hub Pricing\ICE Oil Options\ICE
Dat to Excel.xlsm", 0, False)
ObjExcel.Application.Visible = True
objExcel.Application.Run "Module3.Save_Close_TN"
objExcel.Application.Run "Module2.SaveAs1"
xlBook.Save
xlBook.Close True
set xlBook = Nothing