17.6. Suppressing Alerts

Many of the procedures you build will use message boxes or dialog boxes to allow the user to choose options for the procedure. In some applications — such as Word, Excel, PowerPoint, and Access — you can use the DisplayAlerts property of the Application object to suppress the display of message boxes and errors while a procedure is running:

  • In Word, DisplayAlerts can be set to wdAlertsNone (0) to suppress alerts and message boxes, wdAlertsMessageBox (-2) to suppress alerts but display message boxes, or wdAlertsAll (-1, the default) to display all alerts and message boxes. DisplayAlerts is a sticky setting. You need to set DisplayAlerts explicitly back to one of four things: to True or to wdAlertsAll when you want to see alerts again after setting it to False; to wdAlertsNone; or to wdAlertsMessageBox. VBA resets the default value when you restart Word.

  • In Excel, DisplayAlerts is a read/write Boolean property that can be set to True to display alerts and False to suppress them. The setting sticks until you change it or restart Excel, at which point VBA resets it to True.

  • In PowerPoint, DisplayAlerts is a read/write property that can be set to ppAlertsAll to display all alerts and ppAlertsNone to suppress all alerts. The setting sticks until you change it or until you restart PowerPoint, at which point VBA resets it to ppAlertsNone.

  • In Access, you use the pervasive DoCmd object's SetWarnings method, like this:

    DoCmd.SetWarnings False

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.201.242