Solved

Excel VBA - Error Handler Class

Posted on 2014-01-08
3
532 Views
Last Modified: 2014-02-25
Has anyone created an Error Handler Class in Excel VBA?

I've seen this
Previous discussion 2009

Thanks.
0
Comment
Question by:hindersaliva
3 Comments
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 39767060
I'm not sure what you mean as each object needs to handle its own errors using the built in Err object
What are you ring to achieve that you can't with On Error Goto [label] etc
0
 
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 250 total points
ID: 39767269
This is the first thing I looked for when I started programming in VB in 1992.

Surprised to see that none existed, I had just found out a way to become a millionnaire.

I worked on the thing for a while, and saw quite fast why there was nothing like that anywhere.

There are so many ways that a given error could be handled that everytime I wanted to use my error library, I ended up having to add a Case or a If to handle the way I needed to handled the error in the current application.

Take the simple problem of trying to react to a "File not found".

- Do you ask the user to tell you where the file is located?
- Do you display an interface that lets the user navigate to the file?
- Do you create a new file with a default name?
- Do you create a new file after asking the user for a name?
- If you decide on the last one, do you also ask for a location?
- Can the application continue to work without that file, or do you have to close everything?

Every appliction will have its own way of reacting to that situation. It is finally easier to deal with the problem in the module or sheet that gets the error than using an external class that always end up not providing the feature that you need at that specific point in the code.

It might be possible to build one for a specific application. But not a general class that you can reuse everywhere.
0
 
LVL 35

Accepted Solution

by:
[ fanpages ] earned 250 total points
ID: 39767695
Hi,

Has anyone created an Error Handler Class in Excel VBA?

Dick Kusleika has just published an example via his Blog ("Daily Dose of Excel") based on ideas he developed from the "Professional Excel Development: The Definitive Guide to Developing Applications Using Microsoft Excel, VBA, and .NET" (2nd Edition) Paperback book written by Rob Bovey, Dennis Wallentin, Stephen Bullen, & John Green:

"Error Handling via an Error Class" (January 2, 2014, 12:34 pm)
[ http://dailydoseofexcel.com/archives/2014/01/02/error-handling-via-an-error-class/ ]

BFN,

fp.
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

This is an explanation of a simple data model to help parse a JSON feed
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

867 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

21 Experts available now in Live!

Get 1:1 Help Now