My script was running just fine up until about a week ago. Now it throws an error on the macro run statement.
The macro runs fine in the spreadsheet when run manually. We did run windows updates, and an antivirus update; but that should not have changed anything in this - right?
I'm running windows 10, and Excel 2010.
Here's my script:
Dim oExcel
Dim gfuncs
Dim oBook
'determine whether the folders exist for data source and output; create the year directory if it does not already exist.
'look for source file
sSourceFile = "\\... myspreadsheetwithAmacro.xlsm"
set objFSO = createobject("scripting.filesystemobject")
if objFSO.fileexists(sSourceFile) then
else
wscript.echo "cannot find source file" & sSourceFile
end if
'--Start Excel and run it invisibly
Set oExcel = CreateObject("Excel.Application")
'oExcel.Visible = false
oExcel.displayalerts=true
'--Note: The act of opening the workbook will cause the functions to update
oExcel.Workbooks.open sSourceFile
oExcel.application.visible = true
oExcel.application.Run ("macro1") <-- this is the "unknown runtime error" line
oexcel.activeworkbook.close
oExcel.displayalerts=true
oexcel.workbooks(ssourcefile).close
oExcel.Quit
The macro runs fine in the spreadsheet when run manually. We did run windows updates, and an antivirus update; but that should not have changed anything in this - right?
I'm running windows 10, and Excel 2010.
Here's my script:
Dim oExcel
Dim gfuncs
Dim oBook
'determine whether the folders exist for data source and output; create the year directory if it does not already exist.
'look for source file
sSourceFile = "\\... myspreadsheetwithAmacro.xlsm"
set objFSO = createobject("scripting.filesystemobject")
if objFSO.fileexists(sSourceFile) then
else
wscript.echo "cannot find source file" & sSourceFile
end if
'--Start Excel and run it invisibly
Set oExcel = CreateObject("Excel.Application")
'oExcel.Visible = false
oExcel.displayalerts=true
'--Note: The act of opening the workbook will cause the functions to update
oExcel.Workbooks.open sSourceFile
oExcel.application.visible = true
oExcel.application.Run ("macro1") <-- this is the "unknown runtime error" line
oexcel.activeworkbook.close
oExcel.displayalerts=true
oexcel.workbooks(ssourcefile).close
oExcel.Quit