Solved

Excel VBA - Error Handler Class

Posted on 2014-01-08
3
527 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

A short article about problems I had with the new location API and permissions in Marshmallow
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.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

743 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

12 Experts available now in Live!

Get 1:1 Help Now