Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default globally catching any error event?

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default globally catching any error event?

"RB Smissaert" wrote in message
...
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 procedu

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default globally catching any error event?

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

"Rob Bovey" wrote in message
...
"RB Smissaert" wrote in message
...
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 procedu

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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I globally set "error message" parameters in Excel Evansct Excel Worksheet Functions 5 November 17th 05 05:13 PM
Catching VbMsgBoxResult jose luis Excel Programming 2 October 31st 04 06:43 AM
Catching NewSheet-Event in another WorkBook Christoph Basedau Excel Programming 3 October 8th 04 12:01 PM
Catching an error Shannon Excel Programming 1 December 8th 03 08:22 PM
[how to] VBA catching close/print in printpreview Héctor Miguel Excel Programming 0 August 16th 03 02:28 AM


All times are GMT +1. The time now is 03:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"