How to configure macro to run automatically in Access 2007

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

Please note that I do not want there to be any human intervention, it should be able to start automatically if someone does not open access to run autoexec or onload or something like that.

Is it possible?

+4
source share
3 answers

You can use the MS Access command line switch to run the macro. If you search for “commandline” in Access help, in the “Launch Command Line Options” section, you will find all the command line switches. The switch to run the macro is x macro .

So, if you write your macro to run whatever you want and exit Access when it finishes, you can create a command line that will do the trick and put it in a batch file that the Windows task scheduler can execute.

However, as I said in the comment above, if you just run some queries, I would say that it makes sense to bypass access completely and use DAO directly in the scheduled vbScript to execute the requests.

+6
source

You can use the Windows and VBScript task scheduler to run code or launch Access.

+4
source

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 ("FULLPATH \ msaccessdb")

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

  • THEN create file.bat

    @echo off
    cscript schedule.vbs

and you are 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

+3
source

All Articles