runtime error catcher

  • Thread starter Thread starter associates
  • Start date Start date
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top