Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
General question re Error Handling
hello experts
This is just a general question for my own education. I've dabbled in a fair amount of Access VBA in the past, but have just started learning about Excel VBA. In Access, we would use Error Handling in almost every sub, but In Excel, error Handling seems to be the exception rather than the rule. I can't even find much about it in the Excel VBA help, and there are relatively few references to it in this forum. What gives? Just Curious Terry W. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
General question re Error Handling
Terry, I use it all the time. My favorite approach is:
Public Const bDebug as boolean = true or false (depending on need) Sub Main_Routine_With_Error_Trap() if not bdebug then on error goto etrap Main_Procedure exit sub etrap: msgbox "Woops " & err.desription End Sub The above, with a better message obviously, traps all errors except those in procedures in user forms. I thus tend to not run any elaborate user form code other than input validation. If I'm debugging code, I set bDebug to True. When I'm done, I set to False. And, I put a If statement in the auto_close to warn me if bDebug is true. Some use of On Error Resume Next to avoid errors and then testing the result to see what actually happened. For example Dim wB as workbook set wB = Nothing On error resume next set wB = workbooks("My workbook.xls") on error goto 0 if wb is nothing then msgbox "My workbook.xls is not open" Robert Flanagan http://www.add-ins.com Productivity add-ins and downloadable books on VB macros for Excel "terry w" wrote in message ... hello experts This is just a general question for my own education. I've dabbled in a fair amount of Access VBA in the past, but have just started learning about Excel VBA. In Access, we would use Error Handling in almost every sub, but In Excel, error Handling seems to be the exception rather than the rule. I can't even find much about it in the Excel VBA help, and there are relatively few references to it in this forum. What gives? Just Curious Terry W. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
General question re Error Handling
Chip Pearson shares a lot of notes:
http://www.cpearson.com/excel/ErrorHandling.htm terry w wrote: hello experts This is just a general question for my own education. I've dabbled in a fair amount of Access VBA in the past, but have just started learning about Excel VBA. In Access, we would use Error Handling in almost every sub, but In Excel, error Handling seems to be the exception rather than the rule. I can't even find much about it in the Excel VBA help, and there are relatively few references to it in this forum. What gives? Just Curious Terry W. -- Dave Peterson |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
General question re Error Handling
Thanks Robert and Dave. This was quite helpful.
Terry W. "Dave Peterson" wrote: Chip Pearson shares a lot of notes: http://www.cpearson.com/excel/ErrorHandling.htm terry w wrote: hello experts This is just a general question for my own education. I've dabbled in a fair amount of Access VBA in the past, but have just started learning about Excel VBA. In Access, we would use Error Handling in almost every sub, but In Excel, error Handling seems to be the exception rather than the rule. I can't even find much about it in the Excel VBA help, and there are relatively few references to it in this forum. What gives? Just Curious Terry W. -- Dave Peterson . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Another Error Handling Question | Excel Programming | |||
ERROR HANDLING question | Excel Programming | |||
error handling question | Excel Programming | |||
Error handling question | Excel Programming | |||
question error handling | Excel Programming |