Hello,
I been attempting to auto run a Excel VBA script every week using the Windows 10 Task Scheduler with no success. Now I am at the limitation of my Task Scheduler skills needing your help to solve this issue.
I've created 3x files Excel xlsm, VBS & batch file (see all 3x code sections listed at the end of this posting)
Any help or advice would be greatly appreciated.
Best regards,
Don
1. Excel VBA script (configured to run once the excel file is opened)
2. script2.vbs (VBScript )
3. run.bat (Batch File)
I been attempting to auto run a Excel VBA script every week using the Windows 10 Task Scheduler with no success. Now I am at the limitation of my Task Scheduler skills needing your help to solve this issue.
I've created 3x files Excel xlsm, VBS & batch file (see all 3x code sections listed at the end of this posting)
- Running the bat file outside of task scheduler all seem to work as expected.
- But once I include the batch file"run.bat" in Task Scheduler the file seems to run but the Excel section doesn't execute at all and no Errors been generated to understand why.
Any help or advice would be greatly appreciated.
Best regards,
Don
1. Excel VBA script (configured to run once the excel file is opened)
VBA Code:
Sub SoTime()
Application.DisplayAlerts = False
MsgBox "Today is " & Format(Date, "dddd - mm/dd/yyyy" & " " & Format(Time, "hh:mm"))
End Sub
2. script2.vbs (VBScript )
VBA Code:
Dim ObjExcel, ObjWB
Set ObjExcel = CreateObject("Excel.Application")
'ObjExcel.Visible = True
'vbs opens a file specified by the path below
Set ObjWB = ObjExcel.Workbooks.Open("C:\Users\dcg38\Documents\VBA code\TestingAutomatedScript.xlsm")
'either use the Workbook Open event (if macros are enabled), or Application.Run
ObjWB.Close False
ObjExcel.Quit
Set ObjExcel = Nothing
3. run.bat (Batch File)
VBA Code:
cscript script2.vbs "C:\Users\dcg38\Documents\VBA code\TestingAutomatedScript.xlsm"