- I have a macro that I need to be run every 5 min. I have a
vbs
file that schedules the macro. - 我有一个宏,我需要每5分钟运行一次。我有一个调度宏的vbs文件。
- The macro is checking for new files in some folder, writes their info into a table, and moving the files into archive.
- 宏正在检查某个文件夹中的新文件,将其信息写入表中,并将文件移动到存档中。
- The table is in the same excel file as the macro!
- 该表与宏在同一个excel文件中!
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
1 个解决方案
#1
5
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
#1
5
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