简体   繁体   English

如何使用Windows Task Scheduler在每个星期一运行Excel宏

[英]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.

相关问题 如何每天使用Windows Task Scheduler运行宏 - How to run a macro daily using windows task scheduler 如何在使用任务计划程序打开而不是手动打开时运行 Excel 宏? - How to run Excel macro on open with Task Scheduler but not on manual open? 使用Excel vba宏通过Windows计划任务运行 - Using Excel vba Macro to be run through Windows Schedule Task 从任务计划程序/SQL Server JOB 运行 Excel 宏 - Run Excel Macro from Task Scheduler / SQL Server JOB 仅当任务计划程序打开excel文件时才可以运行宏吗? - Is it possible to run macro only when excel file is opened by Task Scheduler? 使用任务计划程序在 Excel 中运行 selenium v​​ba 宏时,如何修复“运行时错误 429:ActiveX 组件无法创建对象”错误? - How to fix "Run time error 429: ActiveX Component Can't Create Object" Error when using Task Scheduler to run a selenium vba macro in Excel? Excel 宏通过 powershell 运行,但在 Windows 任务计划程序运行时不运行 - Excel macros run through powershell but not when run by windows task scheduler 仅当 Windows 任务计划程序打开文件时才运行 Excel VBA - Run Excel VBA only if Windows task scheduler opened the file 在创建 excel 文件的任务计划程序窗口上运行脚本 - Run script on Task Scheduler windows where an excel file is created 设置Windows任务计划程序以在5分钟后打开excel并执行excel宏 - Set a windows task scheduler to open excel and execute an excel macro after 5 minutes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM