如何使用Windows任务计划程序设置xlsm文件的重复计划 [英] How to set recurring schedule for xlsm file using Windows Task Scheduler

查看:509
本文介绍了如何使用Windows任务计划程序设置xlsm文件的重复计划的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 xlsx 启用宏的文件。如何在任务管理器中设置它,以便每天上午9点的任务管理器打开工作簿,触发宏并关闭工作簿。

I have a xlsx macro enabled file . How can I set it in the task manager so that everyday at 9 AM task manager would open the workbook, fire the macro and close the workbook.

到目前为止,我正在使用

So far i am using

Application.OnTime。 。

但是我意识到保持xlsm文件是不方便的

But i realize that keeping the xlsm file open is inconvenient

推荐答案

更好地使用 vbs 如你所说


  1. 创建一个简单的 vbs ,这是一个文本文件与 .vbs 扩展名(见下面的示例代码)

  2. 使用任务计划程序运行 vbs

  3. 使用 vbs 在预定的时间打开工作簿然后是:

    • ThisWorkbook中使用 Private Sub Workbook_Open()事件模块在文件打开时运行代码

    • 更强壮(因为宏可能在打开时被禁用),使用 Application.Run
  1. Create a simple vbs, which is a text file with a .vbs extension (see sample code below)
  2. Use the Task Scheduler to run the vbs
  3. Use the vbs to open the workbook at the scheduled time and then either:
    • use the Private Sub Workbook_Open() event in the ThisWorkbook module to run code when the file is opened
    • more robustly (as macros may be disabled on open), use Application.Run in the vbs to run the macro

请参阅在Windows任务计划程序中运行Excel

样本vbs

Dim ObjExcel, ObjWB
Set ObjExcel = CreateObject("excel.application")
'vbs opens a file specified by the path below
Set ObjWB = ObjExcel.Workbooks.Open("C:\temp\rod.xlsm")
'either use the Workbook Open event (if macros are enabled), or Application.Run

ObjWB.Close False
ObjExcel.Quit
Set ObjExcel = Nothing

这篇关于如何使用Windows任务计划程序设置xlsm文件的重复计划的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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