Access Macro Scheduler

  1. Access Scheduled Email Report
  2. Schedule Access Tasks
Active5 years, 10 months ago

I'd like to have a macro, called Macro1, for example, run every day at 9 AM. It works great on its own from the VB code editor in Access 2007 but I would like it to be able to execute automatically without access being open.

Access run macro automatically

Please note that I don't want there to have to be any human intervention, it needs to be able to run automatically without someone opening Access to trigger autoexec or onload or something similar.

Is this at all possible?

Recently someone asked in the forums how to “Automatically Detect MS Office Install Location” so that they could run an Access macro. Well, there are ways to get the path of an installed Office application, but it isn’t necessary in order to run an Access macro. If you need to print a report, or do some other Access task, on a regular basis, you can do this using a VBScript, a batch file and the Windows Task Scheduler. This article shows how. Access Database. The sample database, Scheduling Task (AA 252).mdb, has some tables from the old Northwind sample database, and a simple Orders report. Application.Quit as last expression to be executed within the macro (or running code). As for the confirmation that the scheduled process was ended, it seems that it comes from the Task Scheduler.

alexcocoalexcoco
5,2125 gold badges22 silver badges37 bronze badges

3 Answers

You can use a MS Access command line switch to run a macro. If you search for 'commandline' in Access help, the topic 'Startup command-line options' gives you all the commandline switches. The switch for running a macro is x macro.

So, if you write your macro to run whatever you want and have it exit Access when it finishes, you can then create a commandline that will do the trick and put it in a batch file that the Windows Task Scheduler can execute.

However, as I said in a comment above, if you are just running some queries, I'd say it makes more sense to bypass Access entirely and use DAO directly in a scheduled vbScript to execute the queries.

David-W-Fenton

Access Scheduled Email Report

David-W-Fenton
21.4k3 gold badges39 silver badges53 bronze badges

You can use Windows Task Scheduler and VBScript to run code or start Access.

FionnualaFionnuala
85.9k7 gold badges96 silver badges133 bronze badges

You must create vbscript to run your macro and create a batch file to schedule your vbscript.

  • vbscript code, save this as schedule.vbs file

    Dim accessApp
    set accessApp = createObject('Access.Application')accessApp.OpenCurrentDataBase('fullpathmsaccessdb')

    accessApp.Run 'Macroname',param1, param2,param3
    accessApp.Quit
    set accessApp = nothing

  • THEN create file.bat

    @echo off
    cscript schedule.vbs

and your ready to schedule it using the windows task scheduler http://www.thewindowsclub.com/how-to-schedule-batch-file-run-automatically-windows-7

hope this help :D

noodlenoodle

Schedule Access Tasks

Not the answer you're looking for? Browse other questions tagged ms-accessmacrosms-access-2007scheduled-tasks or ask your own question.