runtime error catcher

A

associates

Hi,

I just want to ask a question. With the runtime error catcher that i'v
got below, it still shows up empty box when there is no runtime error
It works great if there is a runtime error.

Here is the code

Sub Importfile()
On Error GoTo ErrCheck
FileIn = Application.GetOpenFilename()
slot = FreeFile
Open FileIn For Input As slot
...
ErrCheck:
'show the description of the error
MsgBox Err.Description
End Sub

is this the right way of catching the error?

Thank you very much in advanc
 
A

azidrane

Maybe try putting an "Exit Sub" in there

Sub Importfile()
On Error GoTo ErrCheck
FileIn = Application.GetOpenFilename()
slot = FreeFile
Open FileIn For Input As slot
...

Exit Sub


ErrCheck:
'show the description of the error
MsgBox Err.Description
End Sub

I think it just needs to come at the end of the code, in a place that
it will be run if no error occers.
 
Top