ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Error handling (https://www.excelbanter.com/excel-programming/362571-error-handling.html)

toocold[_26_]

Error handling
 

Good afternoon,

I am working on developing something that has multiple modules and
subs... Anyway, I am wondering if anyone can give me ideas on the most
effective way of dealing with errors if they occur while the program is
running. I don't want users to have the program to freeze up on them.
Instead I would like it to i.e. return to the beginning of the program
or even shut down so that the user has to reload.

I don't know how I can manage this without making a reference in every
sub routine. For instance, could I put something in the "This
Workbook" excel object that would handle the error at anytime the
workbook is open.

2nd question, is there any code that would unload any active
userforms?

Thanks in advance for any ideas!
Cheers,
dw


--
toocold
------------------------------------------------------------------------
toocold's Profile: http://www.excelforum.com/member.php...o&userid=31608
View this thread: http://www.excelforum.com/showthread...hreadid=546022


Jim Thomlinson

Error handling
 
You need to have error handling in every procedure and function. There is no
way around it. What the error handler does in each procedure will be specific
to the error generated. Make sure that your error handler resets all
application level settings such as "Applicaton.displayalerts" ... As a
general rule well written code will rarely if ever invoke the error handler.
That being said good code will handle anything that is thrown at it and deal
with any errors appropriately.
--
HTH...

Jim Thomlinson


"toocold" wrote:


Good afternoon,

I am working on developing something that has multiple modules and
subs... Anyway, I am wondering if anyone can give me ideas on the most
effective way of dealing with errors if they occur while the program is
running. I don't want users to have the program to freeze up on them.
Instead I would like it to i.e. return to the beginning of the program
or even shut down so that the user has to reload.

I don't know how I can manage this without making a reference in every
sub routine. For instance, could I put something in the "This
Workbook" excel object that would handle the error at anytime the
workbook is open.

2nd question, is there any code that would unload any active
userforms?

Thanks in advance for any ideas!
Cheers,
dw


--
toocold
------------------------------------------------------------------------
toocold's Profile: http://www.excelforum.com/member.php...o&userid=31608
View this thread: http://www.excelforum.com/showthread...hreadid=546022




All times are GMT +1. The time now is 08:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com