MS Access running a funtion from scheduled task not working

764 views Asked by At

I am trying to run a macro daily from the windows task scheduler (w8.1 for tesing and server 2012 in production - both have the same problem) my .bat file:

C:\Batch\attrib.exe -r C:\...\db.mdb
rem ping 1.1.1.1 -n 1 -w 10000 > nul
"C:\Program Files (x86)\Microsoft Office 2003\OFFICE11\MSACCESS.EXE" "C:\...\db.mdb" /x "Launch"
ping 1.1.1.1 -n 1 -w 60000 > nul
C:\Batch\attrib.exe +r C:\...\db.mdb
Taskkill /F /IM MSACCESS.EXE

Launch is a macro which calls a function. The function works fine - it updates a mssql db so i can see when it has run successfully. When the scheduled task starts i can see the ms access process start but it doesn't do anything (cpu 0%). The macro does not run. What am i doing wrong? Any help would be much appreciated - i just cant think what else to try

BTW this task used to run on windows server 2003 without issues (though i cannot say for sure if something has changed in the batch file or in the access db).

2

There are 2 answers

0
tomjm On BEST ANSWER

When opening access i was getting security warning which required user confirmation. I changed the security level to low in tool->macros->security to make this go away and success.

On the server i had a different warning saying that the file is corrupt or badly closed. Still have not got round to fixing but shouldn't be too hard.

Conclusion:

Make sure Access can open the file with the appropriate user without warnings.

0
Javier A. Forteza Ibarra On

Do this: Run Regedit

Local User -> Software -> Microsoft-> Office -> Access -> (Office Version) -> Security

Add:

 DWORD 32 - VBAWarnings = 1