DisplayAlerts Property

Applies To

Application Object.

Description

True if Microsoft Excel displays certain alerts and messages while a macro is running. Read-write.

Remarks

Defaults to True. Set this property to False if you do not want to be disturbed by prompts and alert messages while a macro is running, and want Microsoft Excel to choose the default response.

If you set this property to False, Microsoft Excel sets it back to True when your macro stops running.

This property is not effective from outside Microsoft Excel. For example, you can set this property to False from another application (using OLE Automation), but Microsoft Excel will immediately reset it to True. Because OLE Automation calls are processed as single-line macros and Microsoft Excel resets this property whenever a macro stops running, the property is reset immediately after you set it.

Example

This example closes the workbook BOOK1.XLS and does not prompt the user to save changes. Any changes to BOOK1.XLS are not saved.


Application.DisplayAlerts = False
Workbooks("BOOK1.XLS").Close
Application.DisplayAlerts = True

This example suppresses the message that appears when you initiate a DDE channel to an application that is not running.


Application.DisplayAlerts = False
channelNumber = Application.DDEInitiate( _
    app:="WinWord", _
    topic:="C:\WINWORD\FORMLETR.DOC")
Application.DisplayAlerts = True
Application.DDEExecute channelNumber, "[FILEPRINT]"
Application.DDETerminate channelNumber