Application.DisplayAlerts Property (Excel)
Published: July 16, 2012
True if Microsoft Excel displays certain alerts and messages while a macro is running. Read/write Boolean.
The default value is True. Set this property to False to suppress prompts and alert messages while a macro is running; when a message requires a response, Microsoft Excel chooses the default response.
If you set this property to False, Microsoft Excel sets this property to True when the code is finished, unless you are running cross-process code.
When using the SaveAs method for workbooks to overwrite an existing file, the Confirm Save As dialog box has a default of No, while the Yes response is selected by Excel when the DisplayAlerts property is set to False. The Yes response overwrites the existing file.
This example closes the Workbook Book1.xls and does not prompt the user to save changes. Changes to Book1.xls are not saved.
Application.DisplayAlerts = False Workbooks("BOOK1.XLS").Close Application.DisplayAlerts = True
This example suppresses the message that otherwise appears when you initiate a DDE channel to an application that is not running.