I have an Excel 365 workbook with some VBA code, which uses the PISampDat function to pull multiple columns of data. The workbook is run by a batch file, which is in turn triggered by a Windows scheduled task. If I run the workbook or the batch file manually, it works as expected, but if I use the scheduled task, I get the following error:
1004: Cannot run the macro 'PISampDat'. The macro may not be available in this workbook or all macros may be disabled.
It seems like when it's run by the scheduled task, Excel is not loading the DataLink add-in.
- Scheduled task running as admin user which has permissions on all files and folders involved
- Same user can run the task manually
- "Run whether user is logged in or not" option is selected
- "Run with highest privileges" option is selected
- Configured for Windows Server 2012 R2
- "Program/script" option contains only the batch file name
- "Start in (optional)" option contains only the batch file path
- Trust access to the VBA project object model
Any idea how to resolve this?