8关闭工作簿而不保存Close a Workbook without Saving Sub mynzvba_close_Activeworkbook()ActiveWorkbook.Close SaveChanges:=False End Sub Ø本节内容参考程序文件:Chapter03-2.xlsm 9保存并关闭工作簿Close a Workbook after Saving Sub mynzvba_close_workbook()Dim wbCheck As String wbCheck = Dir(...
Workbook Codes 8 关闭工作簿而不保存Close a Workbook without Saving Sub mynzvba_close_Activeworkbook() ActiveWorkbook.Close SaveChanges:=False End Sub 本节内容参考程序文件:Chapter03-2.xlsm 9 保存并关闭工作簿Close a Workbook after Saving Sub mynzvba_close_workbook() Dim wbCheck As String wbCheck...
在Excel VBA 中,我们可以使用 ActiveWorkbook.Close 方法来关闭当前活动的工作簿。然而,如果我们没有保存工作簿,Excel 会提示我们保存工作簿。如果我们想关闭工作簿而不保存更改,我们可以使用 SaveChanges 参数。以下是示例代码: Sub CloseWorkbookWithoutSaving() ActiveWorkbook.Close SaveChanges:=False End Sub 在上面...
8关闭工作簿而不保存Close a Workbook without Saving Sub mynzvba_close_Activeworkbook() ActiveWorkbook.Close SaveChanges:=False End Sub Ø本节内容参考程序文件:Chapter03-2.xlsm 9保存并关闭工作簿Close a Workbook after Saving Sub mynzvba_close_workbook() Dim wbCheck As String wbCheck = Dir(ThisWo...
It’s“Close Workbook Without Saving.xlsm”. Book_Name="Close Workbook Without Saving.xlsm" Visual Basic Copy ⧪ Method 2 – Closing the Workbook We’ll close the workbook using theClose methodofVBA. To close it without saving, we’ll set theSaveChangesparameter of theClose methodtoFalse. ...
I have the following code that is working but the line .close closes the WB without saving: Option Explicit Public Function updateStatus(fpath As String, fname As String, num As String) Dim wk As String, yr As String Dim owb As Workbook Dim trow As Variant With Application .DisplayAlerts...
Steps to Close a Workbook Close a Workbook without Saving Close a Workbook after Saving Related Tutorials You need to use the “Close” method to close an Excel file. With this method, you can specify whether you want to save the changes or not. If you want to save and close a file ...
wb.Close (False)'~~> Close without saving so that next time the reference is still thereThisWorkbook.Close (False)EndSub And this is what happens now NOTE You will have to giveProgrammatic access to Office VBA project Else you will get the below error when you run the code. ...
After making changes to Excel file, if you attempt to close the workbook without saving it first, Excel displays aPromptwindow saying, “Want to save your changes to…”. Similar prompts are displayed when users try to save files in different formats, such asxlsxtoxlsm. ...
As far as I understand it, the VBA code continues execution beyond the Close instruction as soon as the OS is told to close the application instance; without DoEvents, the VBA code does not wait for the Close event to complete. The deallocation (setting xlsApp to Nothing) takes ...