G
Gary Hillerson
I thought I understood "On Error" but I'm thinking that I got it
wrong.
Can someone point me to a clear description of "On Error" and
"Resume?"
I may be confused:
--------------
If I'm calling a single function and want to simply go to the next
statement in case of an error, I can write:
Private Sub MySub.
On Error Resume Next
'some call like Open a file
'other code that will be executed regardless of errors
End Sub
----------------
If i'm calling a bunch of potentially error-causing functions, I
thought I could install an error handler and then simply drop out of
my routine, like this:
Private Sub MySub2
On Error Goto ErrHandler
'some system call
'some code
'another system call
'more code
Exit Sub
ErrHandler:
MsgBox "Got an Error"
Exit Sub
But in reading Word 2003's help, it sounded like you have to have a
Resume statement or the error handler will stay alive, which I don't
want. Does exiting the subroutine terminate the error handler? If not,
how do I terminate without resuming immediately after the offending
call?
wrong.
Can someone point me to a clear description of "On Error" and
"Resume?"
I may be confused:
--------------
If I'm calling a single function and want to simply go to the next
statement in case of an error, I can write:
Private Sub MySub.
On Error Resume Next
'some call like Open a file
'other code that will be executed regardless of errors
End Sub
----------------
If i'm calling a bunch of potentially error-causing functions, I
thought I could install an error handler and then simply drop out of
my routine, like this:
Private Sub MySub2
On Error Goto ErrHandler
'some system call
'some code
'another system call
'more code
Exit Sub
ErrHandler:
MsgBox "Got an Error"
Exit Sub
But in reading Word 2003's help, it sounded like you have to have a
Resume statement or the error handler will stay alive, which I don't
want. Does exiting the subroutine terminate the error handler? If not,
how do I terminate without resuming immediately after the offending
call?