[英]Use vbs to open an excel workbook, run a macro and save the workbook
vbs
file that schedules the macro. vbs
文件。 It is running the macro fine but in the end, its asking me if I wont to save the file. 它正在运行宏,但最后,它问我是否不保存文件。
I need it to save the changes that the macro did to the file automatically! 我需要它来自动保存宏对文件所做的更改!
this is my current vbs
code: 这是我目前的
vbs
代码:
Option Explicit
Dim xlApp, xlBook
Set xlApp = CreateObject("Excel.Application")
xlApp.DisplayAlerts = False
Set xlBook = xlApp.Workbooks.Open("W:\Excel Macro\EIM File Maneger\EIM_file_check.xlsm", 0, True)
xlApp.Run "GetFiles"
xlBook.Close true
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing
WScript.Echo "Finished."
WScript.Quit
Updated code below, I have also tweaked the logic of the clean-up 下面更新了代码,我也调整了清理的逻辑
Dim xlApp, xlBook
Set xlApp = CreateObject("Excel.Application")
xlApp.DisplayAlerts = False
Set xlBook = xlApp.Workbooks.Open("W:\Excel Macro\EIM File Maneger\EIM_file_check.xlsm", 0, True)
xlApp.Run "GetFiles"
xlbook.Save
xlBook.Close False
set xlBook = Nothing
xlApp.Quit
Set xlApp = Nothing
WScript.Echo "Finished."
WScript.Quit
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.