below is a summary of my issue, any guidance you can provide would be greatly appreciated.
Objective: Use the task scheduler to open Excel and execute a macro that sends a PDF of the Excel sheet via Outlook.
Issue: The Excel file relies on a COM add-in (located in the same path as my file, but a few levels up) to pull data for the report that will be distributed. However, when the task scheduler opens an instance of Excel, the required add-in will not load and therefore the report does not update (other add-ins load just fine). All other parts of the process are working as expected.
What We've Tried: Disabled/enabled the update links prompt (automatically set to update w/o asking). I tried opening a random blank Excel file to see if the add-in would load (it did not). Ensured that all other instances of Excel (i.e., ghost Excels) are closed from the task manager. Reached out to the developers of the add-in, but have not heard back yet. FWIW, when I manually do exactly the steps outlined in the script, everything works fine. It only fails to load the add-in when the script is used to open Excel.
We're fairly new to using the task scheduler and would welcome your thoughts. I've included the script below for your reference. Please let us know if there is any additional information that might be useful.
Thank you for your time and your assistance.
'Input Excel File's Full Path
ExcelFilePath = "C:\mypath\myfile.xlsb"
'Input Module/Macro name within the Excel File
MacroPath = "Module1.SendPDF"
'Create an instance of Excel
Set ExcelApp = CreateObject("Excel.Application")
'Do you want this Excel instance to be visible?
ExcelApp.Visible = True 'or "False"
'Prevent any App Launch Alerts (ie Update External Links)
ExcelApp.DisplayAlerts = False
'Open Excel File
Set wb = ExcelApp.Workbooks.Open(ExcelFilePath)
'Execute Macro Code
ExcelApp.Run MacroPath
'Save Excel File (if applicable)
wb.Save
'Reset Display Alerts Before Closing
ExcelApp.DisplayAlerts = True
'Close Excel File
wb.Close
'End instance of Excel
ExcelApp.Quit