How do you trap error messages in Word VBA? I looked on the HELP for
an ONERROR command but could not find it. What is the correct way to
trap errors?

Steve Wylie

Re: Error trapping by JB

JB
Mon Oct 25 05:35:05 CDT 2004

Steve Wylie wrote:

> How do you trap error messages in Word VBA? I looked on the HELP for
> an ONERROR command but could not find it. What is the correct way to
> trap errors?
>
> Steve Wylie
Hi Steve,
The Code should look like -

On Error Goto ErrHandle

'Your Code here

ErrHandle:
Msgbox "Your Application Encountered and Error" & Err.number &
Err.Description & Err.Source

Err.clear

Have a look at the Err object and see what can be done (open a form in
VBA and type Err, then highlight and press F1 to get a description).

I normally have a function to handle major errors in the app to which I
pass all the relevant info including preset variables in my Functions

HTH

J

Re: Error trapping by Steve

Steve
Mon Oct 25 05:45:05 CDT 2004

Thanks! I didn't think of doing "On" and "Error" as two separate words.

Steve