Microsoft KB Archive/64140

Error Trapping in Word for Windows

PSS ID Number: Q64140 Article last modified on 03- 9-1993

1.00 1.10 1.10a 2.00 WINDOWS

Summary: It is possible to perform error trapping within Microsoft Word for Windows macros using the On Error commands. These commands will permit you to handle errors generated by Word for Windows in a manner other than it normally would. There are three On Error commands.

On Error Goto
This command would be used to provide an alternate error-handling routine. In a macro it would be implemented as follows: Sub Main On Error Goto Error1. . Error1: . . End Sub

On Error Resume Next
This version of the On Error command will cause all errors to be ignored that normally generate an error message. Use of this command should be carefully planned to avoid incorrect results.

On Error Goto 0
This form of the On Error command will return error handling to its normal operating mode. It will often be paired with the On Error Goto version to permit the special handling of error messages in specific sections of the macro and then return to Word’s normal error-handling routines.

Reference(s): “Microsoft Word for Windows and OS/2 Technical Reference” pages 95-97. Additional reference words: w4wmacro 2.0 2.00