• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User


  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA in task scheduler closes other opened excel tabs after the execution


New Member

I have implemented a macro in vba that refreshes the data from a database and scheduled it using the windows task scheduler. I have attached the vbs code for reference:

>>> use code - tags <<<
ExcelFilePath = "C:\Users\hp\Desktop\TEST\test.xlsm"  ' File path
MacroPath = "test"  ' Macro name
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Visible = True 'or "False"
Set wb = ExcelApp.Workbooks.Open(ExcelFilePath)
ExcelApp.Run MacroPath
Windows task scheduler closes other opened excel tabs after the macro execution. I tried executing on other systems also. Sometimes it's working (doesn't close all excels) sometimes it doesn't.

Please help me resolve this issue.
Last edited by a moderator:

Marc L

Excel Ninja
As this is a wild cross posting you must read the forums rules and do the necessary :​