Solved

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

Posted on 2008-06-12
2
140 Views
Last Modified: 2010-04-30
When prog. has already jumped to ErrorHandler?
(Can't disable error handling in this case)
0
Comment
Question by:davidsperling
2 Comments
 
LVL 81

Accepted Solution

by:
zorvek (Kevin Jones) earned 500 total points
ID: 21767176
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
 
LVL 4

Author Comment

by:davidsperling
ID: 21767197
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now