Article ID: 213428 - Last Review: May 28, 2007 - Revision: 5.1 How to suppress "Save Changes" prompt when you close a workbook in ExcelThis article was previously published under Q213428
For a Microsoft Excel 97 and earlier version of this article, see 129153
(http://support.microsoft.com/kb/129153/
)
.
On This PageSUMMARY
In Microsoft Excel, you can create a Microsoft Visual Basic for
Applications (VBA) macro that suppresses the "Save Changes" prompt when you
close a workbook. You can do this either by specifying the state of the
workbook's Saved property or by suppressing all alerts for the workbook.
MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure. However, they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To use either of the following examples, follow these steps:
You can use the reserved subroutine name "Auto_Close" to specify a macro that should run whenever a workbook is closed. By doing this, you can control how the document is handled when the user is finished and has instructed Excel to close the document. Example 1: Close the workbook without saving changesTo force a workbook to close without saving any changes, type the following code in a Visual Basic module of that workbook:The DisplayAlerts property of the program can be used for the same purpose. For example, the following macro turns DisplayAlerts off, closes the active workbook without saving changes, and then turns DisplayAlerts on again. The following macro closes the workbook without saving changes: Example 2: Close the workbook and save the changesTo force a workbook to save changes, type the following code in a Visual Basic module of that workbook: | Article Translations
|
Back to the top
