Hi, I am facing problem for Task Scheduler to run a excel macros. When I run the Vbscript in Task Scheduler, the status shows running but nothing happen. I open the excel file manually and it shows below reasons, so i have to end the excel using task manager to let me access to the file again
Microsoft Excel cannot access the file "" There are several possible reasons:
-The file name or path does not exist.
-The file is being used by another program.
-The workbook you are trying to save has the same name as a currently open workbook.
My VBS:
My last 4 lines of VBA:
Microsoft Excel cannot access the file "" There are several possible reasons:
-The file name or path does not exist.
-The file is being used by another program.
-The workbook you are trying to save has the same name as a currently open workbook.
My VBS:
'Create Excel App Instance & Open Xlsm File
Set objExcelApp = CreateObject("Excel.Application")
objExcelApp.Visible = True
objExcelApp.DisplayAlerts = False
'Define Macro File & Path
sFilePathXlsm = "C:\Users\roeyj\OneDrive\Desktop\Intern\Monthly PM\Service Contracts as of 2022 (macro).xlsm"
Set iWb = objExcelApp.Workbooks.Open(sFilePathXlsm)
'1. Run 1st Macro in another Excel
objExcelApp.Run "'" & iWb.Name & "'!Sheet3.contract_vba"
'Save & Close file
iWb.Close
iwb.Save
objExcelApp.DisplayAlerts = True
objExcelApp.Quit
objExcelApp.Run "'" & iWb.Name & "'!Sheet3.contract_vba"
My last 4 lines of VBA:
Sheets("Monthly PM").Delete
ActiveWorkbook.Save
Application.Quit
End Function