I have a VBA macro for extracting some data daily. The Macro doesn't have any interactive component like a Message Box, Custom Inputs, or Input Box. It doesn't expect any user input, it only downloads some data from a DB and generates some CSVs.
My task is to automate its extraction using Windows' Task Scheduler.
I tried to create a VBS app to run it like here:
https://stackoverflow.com/questions/58139154/running-an-excel-macro-from-task-scheduler
It didn't work.
I created my own C# app to run it and didn't work.
At this point, I'm stuck because the VBS app and the C# app run the macro properly if I run it manually.
I have tried the following combinations:
- Run only when the user is logged on. -> Successful.
- Run whether user is logged or not. -> Failed.
- Run whether user is logged or not. Plus, Run with the highest privileges. -> Failed.
- Run whether user is logged or not. Plus, Do not store password ... -> Failed.
- Run whether user is logged or not. Plus, Do not store password ... And Run with the highest privileges -> Failed.
- Run whether user is logged or not. Plus, Run with the highest privileges and Hidden. -> Failed.
- Run whether user is logged or not. Plus, Do not store password ... and Hidden -> Failed.
- Run whether user is logged or not. Plus, Do not store password ..., Run with the highest privileges and Hidden -> Failed.
Also, I tried to schedule the VBA macro too and there was no difference (this was my first attempt).
Additionally, as I highlighted in the comments. I have tested with my account that is an Admin account and a service account that is already certain scheduled tasks.
Furthermore, the commands look like these ones:
C:\...\MacroRunner.exe
C:\...\MacroRunner.vbs
Both run in the CMD. Also, I have tried to run each of them manually. I didn't expect only that the scheduled time executed it.
Any idea what could I be doing wrong? Thanks for your time.
P.S.:
If you read the StackOverflow question, the person is facing the same issue, but he is looking for code. I'm personally convinced this is a Server issue, not a code issue.
Also, it's not the first place where you can find similar topics:
https://www.thespreadsheetguru.com/blog/how-to-automatically-run-excel-vba-macros-daily