vba 如何将 Excel 文件作为任务或作业运行?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8189573/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 14:29:24  来源:igfitidea点击:

How can I Run Excel Files as a task or job?

excelvbaexcel-vbaexcel-2010

提问by digitalgavakie

Is it possible to schedule an Excel file to run on a certain day?

是否可以安排 Excel 文件在某一天运行?

I have a file I built that is refreshed from data. I use a cell as the parameter to populate the data feed. I want to see if there is a way to setup a job to run these automatically and save them. If possible save them by a cell in Excel.

我有一个我构建的文件,它是从数据中刷新的。我使用一个单元格作为参数来填充数据馈送。我想看看是否有办法设置一个作业来自动运行这些并保存它们。如果可能,将它们保存在 Excel 中的单元格中。

Any thoughts?

有什么想法吗?

回答by Danny

Use the Windows Scheduler to schedule a task to open up the Excel file. You should then be able to use the Workbook_Open Event to do what you need with the file.

使用 Windows 计划程序安排任务以打开 Excel 文件。然后,您应该能够使用 Workbook_Open 事件对文件执行所需的操作。

回答by brettdj

As Danny and Adil B have pointed out you can use Windows Scheduler to schedule events. But I normally schedule the running of a vbs script to manipulate Excel, rather than open Excel directly - this method provides more control over macro security settings if this is an issue

正如 Danny 和 Adil B 所指出的,您可以使用 Windows Scheduler 来安排事件。但我通常安排运行 vbs 脚本来操作 Excel,而不是直接打开 Excel - 如果这是一个问题,此方法可提供对宏安全设置的更多控制

See this examplefor scheduling a vbs with Windows Scheduler

请参阅此示例以使用 Windows 调度程序调度 vbs

How is your data feed run and do you need assistance with this part?

您的数据馈送如何运行,您是否需要这部分的帮助?