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

查看:23
本文介绍了如何安排宏在 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 任务计划程序可以执行的批处理文件中.

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天全站免登陆