Hi Andrew,
Ack! You've discovered a nasty bug in my error handling chapter. I
personally never put any code that might throw an error into the
UserForm_Activate event so I never ran across this (or have long since
forgotten if I ever did). That led to the horrible untested assumption on my
part that errors in UserForm_Activate would behave like errors in
UserForm_Initialize.
After doing a bit of testing it seems as if you have two choices. Either
use On Error Resume Next to blow past anything that goes wrong or treat
UserForm_Activate as if it were an entry point procedure and be prepared to
handle any potential errors inside the error handler for that procedure.
This bug will get fixed in the next edition of the book. Thanks for pointing
it out.
--
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
wrote in message
oups.com...
In the recent (& extremely useful) Bullen, Bovey, Green book it is
recommended not to put error trapping in the form Initialize or
Activate events but instead to let the error be handled by the
procedure which loaded the form or displayed it. This seems to make
good sense but if an error occurs in my Activate event it does not
cascade back to the calling procedure but instead gives me an error
message. Am I missing something here?
(If the error occurs in the Initialize event then this is handled as
desired).
Thanks,
Andrew