How to reset VBA after error?

  • Thread starter Thread starter John Riddle
  • Start date Start date
J

John Riddle

Hello,

I have many thousands of lines of code in my VBA project for my users.
Occassionally, errors occur that stop VBA from processing code. Closing
Outlook and re-opening resets the project and everything works as expected
again. Or, I can go into the VBA project for them and run the
"Initialize_Handler" routine, close their open items, re-open them and they
work again as expected. What I'm really wanting is a way to monitor and
automate reseting the "Initialize_Handler" routine if code stops executing.
What would be the best way to go about this?

Thanks,

John
 
Can you categorize those errors that stop the VBA code from running? If so
just set up an error handler that's called when any of those errors occur
and call your init code from the error handler.
 
Ken,

Thanks for your help. Could you give me an example of "Categorizing" the
errors? I did think of running the Initialize_Handler routine on such errors,
that routine also resets my Inspectors and Explorers collection and would
require me to close all their open items so that they too could be re-set. I'm
hoping not to have to do this very often.

Thanks,

John

Can you categorize those errors that stop the VBA code from running? If so
just set up an error handler that's called when any of those errors occur
and call your init code from the error handler.
 
Well, if error 0x800001001 or whatever causes VBA to stop that would be one
error that you'd handle that way. I just made up that number of course. You
can also set a module level or global level boolean that tells you if this
is the first time the init code has been run. If it is then init whatever
you want, if not then only init the things that are absolutely necessary.

You'll have to experiment to see what errors are doing it, I don't have a
list of them that would stop VBA.
 
Back
Top