如何安排宏以在Access 2007中自动运行 [英] How can I schedule a Macro to run automatically in Access 2007

查看:460
本文介绍了如何安排宏以在Access 2007中自动运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,我想有一个名为Macro1的宏,它每天早上9点运行.它可以通过Access 2007中的VB代码编辑器单独运行,但是我希望它能够在不打开访问的情况下自动执行.

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来触发autoexec或onload或类似的东西.

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.

这有可能吗?

推荐答案

您可以使用MS Access命令行开关来运行宏.如果在Access帮助中搜索命令行",则主题启动命令行选项"为您提供了所有命令行开关.用于运行宏的开关是x macro.

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.

因此,如果您编写宏以运行所需的宏,并在宏完成时退出Access,则可以创建一个命令行来完成此操作,并将其放入Windows Task Scheduler可以执行的批处理文件中.

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.

但是,正如我在上面的评论中说的那样,如果您只是在运行一些查询,我认为完全绕过Access并在计划的vbScript中直接使用DAO来执行查询更有意义.

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.

这篇关于如何安排宏以在Access 2007中自动运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆