如何安排对MS Access宏的呼叫? [英] How to schedule a call to an MS Access macro?

查看:91
本文介绍了如何安排对MS Access宏的呼叫?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望安排对MS Access宏的调用.这个宏使用一个.csv文件(我每天都会收到)来更新SharePoint日历.有人可以解释一下如何在Windows 7计算机上安排每日调用来运行此宏(我正在使用Access 2003,例如EventsCalendar.accdb和名为Run1的宏)吗?我需要使其自动化才能每天早上运行.

I'm looking to schedule a call to an MS Access macro. This macro uses a .csv file (that I get daily) to update a SharePoint calendar. Could someone please explain how to schedule a daily call to run this macro (I'm using Access 2003, say EventsCalendar.accdb and macro called Run1) on my Windows 7 machine? I need to automate it to run every morning.

谢谢!

推荐答案

编写一个可以直接从Windows运行宏的VBScript脚本.为此,您可以先在脚本中创建一个Access应用程序对象,然后将该Access对象放置在脚本中需要它的所有调用之前.例如,

Write a VBScript script that can run the macro straight from Windows. You can do this by first creating an Access application object in your script and then placing this Access object before all calls in the script which need it. For example,

' RunMyMacro.vbs

set accessApp = CreateObject("Access.Application")

accessApp.OpenCurrentDatabase "C:\db\mydb.accdb"
accessApp.DoCmd.RunMacro "MyMacroName"
accessApp.CloseCurrentDatabase
accessApp.Quit

set accessApp = nothing

此脚本现在可以从Windows Shell或命令行运行:

This script is now runnable from the Windows shell or from the command line:

C:\db>cscript //B //Nologo  RunMyMacro.vbs

因此您可以将其安排为Windows计划的任务.

And so you can schedule it as a Windows scheduled task.

这篇关于如何安排对MS Access宏的呼叫?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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