Name
Application.DisplayAlerts [= setting
]
Synopsis
True displays standard Excel dialogs while a macro runs; False hides those dialogs and automatically uses the default response for each. Default is True.
Set this property to False for batch operations in which you don’t want user intervention; be sure to reset the property to True when done. For example, the following code closes all workbooks but the current one without saving or prompting the user:
Sub CloseAllNoSave( ) Dim wb As Workbook ' Turn off warnings. Application.DisplayAlerts = False For Each wb In Workbooks ' Close all workbooks but this one. If Not (wb Is ThisWorkbook) Then _ wb.Close Next ' Turn warnings back on. Application.DisplayAlerts = True End Sub
Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.