I am trying to run a macro using task scheduler and it looks like it executes the VBScript file but it doesn't actually execute any of the code in the macro.
The pathway for the workbook is C:\Users\cdurrell\Desktop\Test Auto 1.xlsm
The macro is called TestAuto
And the Script file has the pathway C:\Users\cdurrell\Desktop\TestAutoScript.txt
I originally was using the following script file
'Write Excel.xls Sheet's full path here
strPath = "C:\Users\cdurrell\Desktop\Test Auto 1.xlsm"
'Write the macro name - could try including module name
strMacro = "Update" ' "Sheet1.TestAuto"
'Create an Excel instance and set visibility of the instance
Set objApp = CreateObject("Excel.Application")
objApp.Visible = True ' or False
'Open workbook; Run Macro; Save Workbook with changes; Close; Quit Excel
Set wbToRun = objApp.Workbooks.Open(strPath)
objApp.Run strMacro ' wbToRun.Name & "!" & strMacro
wbToRun.Save
wbToRun.Close
objApp.Quit
'Leaves an onscreen message!
MsgBox strPath & " " & strMacro & " macro and .vbs successfully completed!", vbInformation
'
and it would make the excel workbook read only and not execute the code in the macro.
Then I took out the line
wbToRun.Save
and now it doesn't make the excel workbook read only but it still doesn't execute the code.
Any pointers or corrections are welcome! Thanks!