Home‎ > ‎StuffLearned‎ > ‎

Task Scheduler for a msaccess macro

posted Dec 9, 2013, 11:35 PM by Brian Grenier   [ updated Dec 10, 2013, 11:21 PM ]
Was struggling to get task manager working for printing a pdf
Multiple instances of MSAccess were running, I closed them and then I could see the error message
'runmacro action was killed'

Here is a script that I tried:
Dim accessApp
set accessApp = CreateObject("Access.Application")
accessApp.OpenCurrentDatabase "C:\Program Files (x86)\UDD\UDDReports.accdb" 
accessApp.DoCmd.RunMacro "OOWListPost" 'here I get the run macro action canceled
set accessApp = nothing

Made a module to delete the old file
Public Function KillOOWListPost()
    Kill "C:\Out of Work\OOWListPost.pdf"
End Function

then in task scheduler:


"C:\Program Files\Microsoft Office\Office14\MSACCESS.EXE" 
Arguments: "C:\Program Files (x86)\UDD\UDDReports.accdb"   /x “OOWListPost”

Start in:
C:\Program Files (x86)\UDD\  (no quotes in 'Start in')

Found that the argument to start the Macro did not work, so made an AUtoExec macro.

Further issue was MSAccess was not closing after printing the pdf. So, in the AutoExec, I added:

Macro pic