Is there a way of knowing on wich line an error occured?

When prog. has already jumped to ErrorHandler?
(Can't disable error handling in this case)
LVL 4
davidsperlingAsked:
Who is Participating?
 
zorvek (Kevin Jones)ConsultantCommented:
Nope. It's one of those annoying things about VB/VBA error handling.

What you can do is add line numbers. VB and VBA error handling includes the ability to display the line number of the statement in error with the following caveats: the line number is only accessible from within the routine where the error occurred, and line numbers reduce the ability to maintain code. That said, the line number is access using the Erl variable:

10   On Error GoTo MyRoutine_Error
20   ...
80   Exit Sub
MyRoutine_Error:
90   MsgBox "Error """ & Err.Description & """ occurred at line " & Erl & " of MyRoutine"

A third party tool that can add and remove line numbers in a VB or VBA project can be found http://www.mztools.com/v3/download.aspx.

Kevin
0
 
davidsperlingAuthor Commented:
Well, if you can't disable error handling you can't add line numbers to the code either ;-) (It's n add-in I cannot change)

Thanks anyway, the points are your's :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.