我有一个脚本打开excel文件并运行宏,然后退出该文件.由于文件处于只读模式,并且脚本对文件进行临时更改,因此当脚本调用myExcelWorker.Quit()excel询问我是否要保存更改时,必须单击"否".有没有办法退出程序并跳过此框?
' Create a WshShell to get the current directory
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
' Create an Excel instance
Dim myExcelWorker
Set myExcelWorker = CreateObject("Excel.Application")
myExcelWorker.Visible = True
' Tell Excel what the current working directory is
' (otherwise it can't find the files)
Dim strSaveDefaultPath
Dim strPath
strSaveDefaultPath = myExcelWorker.DefaultFilePath
strPath = WshShell.CurrentDirectory
myExcelWorker.DefaultFilePath = strPath
' Open the Workbook specified on the command-line
Dim oWorkBook
Dim strWorkerWB
strWorkerWB = strPath & "\BugHistogram_v2.xlsm"
Set oWorkBook …Run Code Online (Sandbox Code Playgroud)