Microsoft Office Tutorials and References
In Depth Information
Figure 7-3. An error dialog
MsgBox line, in which case the dialog in Figure 7-3 will be displayed. This message gives a
description of the error, obtained from the Error object, which we discuss in the next section.
Figure 7-3. An error dialog
It is important to note the line just before the ERR_EXAMPLE label:
Exit Sub
Without this statement, the error-handling code will always be executed, even when there is no
error! Omitting this line is a common mistake. Note also that labels always end with a colon.
7.5.2 The Error Object
The error object, Err object, belongs to the VBA object model. The most important properties of
this object are:
The VBA error number
The name of the current VBA project
A description of the error
Note that the Clear method of the Err object will clear all of the properties of the Err object,
setting its Number property to 0 (which indicates the absence of an error).
7.5.3 The On Error GoTo 0 Statement
The statement:
On Error GoTo 0
turns off any previous On Error GoTo label statements. Any error occurring subsequently will
be handled by VBA in its own inimitable way.
7.5.4 The On Error Resume Next Statement
The syntax:
Search JabSto ::

Custom Search