Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Generic error trap

  Asked By: Boell    Date: Jan 13    Category: MS Office    Views: 651
  

I am working up an Excel VBA app and would like, for pre-alpha testing,
to have a generic error trap for all code, so users will not be thrown
into the Visual Basic Editor. Is there code for a generic Excel error
trap - just capture all errors and display a message box with the
code.

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Barak Levi     Answered On: Jan 13

This is what I use:

Sub Blah()
On Error GoTo EH

‘Place procedure steps here.
'Handle Errors Gracefully
Exit_EH:
Exit Sub

EH:
MsgBox Err.Number & ": " & Err.Description
Resume Exit_EH
End Sub

 
Answer #2    Answered By: Rosalie Holmes     Answered On: Jan 13

How about one for at the top of a module that catches
all errors  in the module's proceedures. Is there a generic  On_Error
event for worksheet code  modules and VBA modules?

 
Answer #3    Answered By: Zachary Larson     Answered On: Jan 13

Are you looking for an error  trap at project, module or procedure level??

Also be aware that possibly the most accurate is to switch on line numbers
so you ca report the error line as well?

I've "played" with project level error trapping and not gotten anywhere nice.

You can create a global variable and set it to the proc name at the top of
the procedure and then report that. This is pretty easy to do with a 3rd
party add in called MZ-Tools.

 
Answer #4    Answered By: Russell Burns     Answered On: Jan 13

For now, just at the tops of modules.............

 
Didn't find what you were looking for? Find more on Generic error trap Or get search suggestion and latest updates.




Tagged: