Application.DisplayAlerts

When you perform a handful of particular actions you will be prompted by a system alerts dialog box.
This is after a confirmation dialog box to confirm the action.
It is possible to remove these system alert prompts by changing the DisplayAlerts property to False.
When the system alerts have been disabled the default button on the dialog boxes is automatically assumed.
This property will be automatically reset to True after your macro has run but it is good practice to change this explicitly in your code.
The DisplayAlerts property cannot be disabled if you are debugging.


Excel

The DisplayAlerts property will be automatically reset to True at the end of your macro.
It is a good idea to switch it back manually though as soon as possible.

Application.DisplayAlerts = False 
ActiveSheet.Delete
Application.DisplayAlerts = True

Word

The DisplayAlerts property is not automatically reset to wdAlertsAll at the end of your macro.
This has to be switched back manually.

Application.DisplayAlerts = wdAlertLevel.wdAlertNone 
ActiveDocument.Close
Application.DisplayAlerts = wdAlertLevel.wdAlertAll

PowerPoint

The DisplayAlerts property is not automatically reset to wdAlertsAll at the end of your macro.
This has to be switched back manually.

Application.DisplayAlerts = [[ppAlertLevel]].wdAlertNone 

Application.DisplayAlerts = [[ppAlertLevel]].wdAlertAll

Important

The DisplayAlerts property cannot be disabled if you are debugging.


© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext