globally catching any error event?

R

RB Smissaert

Have a .xla add-in that runs a number of routines.
As this may take minutes I set the cursor to xlWait at the beginning of
this.
Now there is a slight problem with this as if there is a VBA error you are
left with the xlWait cursor in the VBE.
Would it somehow be possible to catch any VBA error event and then set the
cursor back to xlDefault?
Thanks for any advice.

RBS
 
R

Rob Bovey

RB Smissaert said:
Have a .xla add-in that runs a number of routines.
As this may take minutes I set the cursor to xlWait at the beginning of
this.
Now there is a slight problem with this as if there is a VBA error you
are left with the xlWait cursor in the VBE.
Would it somehow be possible to catch any VBA error event and then set the
cursor back to xlDefault?
Thanks for any advice.

Hi RB,

I'm assuming there's some main procedure in your add-in that runs the
rest of the procedures. If you place an error handler in this procedure and
there are no error handlers in any of the called procedures, then any errors
in the called procedures will be caught by the error handler in the main
procedure. For example, assume the following is your main procedure:

Sub MainProcedure()

On Error GoTo ErrorHandler

SubProcedure1
SubProcedure2
SubProcedure3

Exit Sub

ErrorHandler:
MsgBox "Error Caught", vbCritical, "Error!"
End Sub

Any errors that occur in SubProcedures1, 2 or 3 will be caught by the
error handler in MainProcedure. Note that the one common case where this
does not hold is when you call a procedure with Application.Run.

--
Rob Bovey, Excel MVP
Application Professionals
http://www.appspro.com/

* Take your Excel development skills to the next level.
* Professional Excel Development
http://www.appspro.com/Books/Books.htm
 
R

RB Smissaert

There is a main procedure, but there are lots of called procedures that have
there own error handling.
I suppose I will have to re-organize my error handling.

RBS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top