How can I schedule a Macro to run automatically in Access 2007

↘锁芯ラ 提交于 2019-11-30 15:17:12

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.

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

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 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!