Syntax
Error Err
Error ErrorNumber
Remarks
Error Err generates the most recent error condition and stops the macro. Error ErrorNumber generates the error condition associated with ErrorNumber. For WordBasic error conditions, which have numbers of less than 1000, Error displays an error message. For Word errors, which have numbers of 1000 or greater, Error generates an error condition, but does not display an error message. Error can be used to test an error trap.
For a list of errors and their numbers, see "Error Messages," later in this part. For more information on error trapping, see On Error and Err.
Example
This example generates WordBasic error condition 53 in order to test the handling of this error. When error condition 53 occurs, Word displays a custom message box; any other error runs the instruction Error Err, which displays the built-in message associated with the error number.
On Error Goto trap Error 53 'Generate error condition trap: If Err = 53 Then MsgBox "Error 53 successfully trapped" Err = 0 Else Error Err End If
See Also
Err, Goto, On Error