[英]How to run an Excel macro every Monday using Windows Task Scheduler
I created a macro that refreshes the data automatically and then it saves the file to a particular folder. 我创建了一个宏,该宏会自动刷新数据,然后将文件保存到特定的文件夹中。 I would like to set up a scheduled job that automatically runs my macro every Monday morning.
我想设置一个计划的作业,该作业在每个星期一早上自动运行我的宏。
How can I achieve this? 我该如何实现?
In the workbook that runs your Macro make sure it is called in the ThisWorkbook
Module Workbook_Open
在运行您的宏的工作簿中,确保在
ThisWorkbook
Module Workbook_Open
调用了它。
Private Sub Workbook_Open()
Call YourMacroHere
End Sub
Then go to Task Scheduler
and select Create Basic Task
然后转到
Task Scheduler
并选择Create Basic Task
Then give your task a name 然后给你的任务起个名字
Click Next
and define your schedule 单击
Next
并定义您的时间表
-> Next -> ->下一步->
-> Next -> Start a Program
->下一步->
Start a Program
-> Next -> Browse
and select your workbook ->下一步->
Browse
并选择您的工作簿
-> Next -> Confirm everything is correct and Finish ->下一步->确认一切正确并完成
This will then, provided your computer is turned on will then open that Workbook every Monday at 9am. 然后,只要您的计算机处于打开状态,它将在每个星期一的上午9点打开该工作簿。 The
Workbook_Open()
event will then fire executing your macro. 然后,
Workbook_Open()
事件将触发执行您的宏。 You may want to add to your code as well to shutdown the workbook after the macro has finished. 宏完成后,您可能还想添加代码以关闭工作簿。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.