Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Excel VBA - Error Handler Class

Posted on 2014-01-08
3
Medium Priority
?
626 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 43

Expert Comment

by:Rob
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 1000 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 1000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
Introduction to Processes
Starting up a Project

886 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