在Excel VBA 中,我们可以使用 ActiveWorkbook.Close 方法来关闭当前活动的工作簿。然而,如果我们没有保存工作簿,Excel 会提示我们保存工作簿。如果我们想关闭工作簿而不保存更改,我们可以使用 SaveChanges 参数。以下是示例代码: Sub CloseWorkbookWithoutSaving() ActiveWorkbook.Close SaveChanges:=False End Sub 在上面...
SubClose_Workbook_Without_Saving()Book_Name="Close Workbook Without Saving.xlsm"OnErrorGoToMessage Workbooks(Book_Name).Close SaveChanges:=FalseMessage:MsgBox"The Workbook is Already Closed",vbExclamationEndSub Visual Basic Copy Developing the Macro to Close a Workbook Without Saving Using Excel VBA ...
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...
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 ...
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...
oRef In oRefS If oRef.Name = RefName Then oRefS.Remove oRef Exit For End If Next '~~> Close the workbook Dim wb As Workbook Set wb = Workbooks(ReferenceWb) wb.Close (False) '~~> Close without saving so that next time the reference is still there ThisWorkbook.Close (False) End ...
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. ...
The first time through the process EXCEL does not close. The second time a second copy of EXCEL is created and at the end of the routine it does close, but the first occurance is still there. If I press the VBA reset (stop) button excel will then terminate....
Step 3:Use the ALT/F11 keys to go back to Excel and run the macroproLessson17c. The value 695 is entered in cell A1 and the following message box appears Step 4:Close Excel without saving anything. You can use the message box to inform the user. You might also ask the user (with...