I've seen many questions like this but none of the suggested solutions are working for me.
I have an Access 2010 Macro named "MAIN" (on 32-bit Office). The database contains ODBC linked tables against different database servers and complex join queries to compare and analyze the data to produce CSV files for importing into a third-party system. The Macro is designed to automatically run these queries and save the results to CSV files for later use by the third-party import tool.
My desire is to run this macro "unattended" so that the files are created on a set schedule regardless of whether a user is logged into the system or not. The target system is running Server 2008 R2 (natively 64-bit Windows).
Many of the answers I see online indicate that Office Automation macros may require a user to be logged in so that the Office program has a valid user desktop session. There are several people who are giving the opposite answer - saying that they can run a Microsoft Access Macro unattended using the Windows Task Scheduler with the option "Run whether user is logged on or not" selected.
The Action is set to "Start a program", with the Program/script set to "C:\Program Files (x86)\Microsoft Office\Office14\MSACCESS.EXE" and arguments set to "C:\Test_Dir\Test_DB.accdb" /nostartup /x MAIN
When I run the scheduled task either at the set time or on-demand, it completes quickly with the MSACCESS ResultCode (return value) of 2004 (equivalent to 0x7D4 hex Run Result). Viewing the output folder shows that no files were created.
If, however, I set the Task "Security options" to "Run only when user is logged on", it runs successfully with a proper ResultCode of 0 (0x0 hex). The output files are created as expected in the desired folder, but this only works while I'm logged into the system.
Please provide potential solutions if you have any suggestions that might work. It seems like I've tried so many alternatives but I must be missing something because nothing is working for scheduling an unattended Access macro while logged out.