From: ras on
I have a VB application in Excel (in Office 2007).
If an error occurs, and the error is caught and err.clear executes,
then all is fine.
If it is not caught, or if I stop the function at this point (with the
Reset button),
events no longer trigger event callbacks!

I added a global function that does: Application.EnableEvents = true
When I run this, in the debugger I see it's already true
and running it does nothing.

To re-enable events I have to quit Excel and restart (losing my
breakpoints).
How do I get events to work again?

thx
(I tried to add this to a similar message, but after submitting it
with "reply to author", didn't see my entry. How do I "reply to
thread"? I'm using http://groups.google.com/group/microsoft.public.excel.programming
....)
From: Rick Rothstein on
Fast and dirty way to reset events quickly is by executing this line of code
in the Immediate Window...

Application.EnableEvents = True

That will handle your stopping the program manually. As for your "if it is
not caught" statement, what do you mean if it is not caught... how is the
error trap set up that it is missing the error?

--
Rick (MVP - Excel)


"ras" <ras(a)metaintegration.net> wrote in message
news:184660a3-d8d6-4c41-8afe-2a95c6ab1ff6(a)a37g2000prf.googlegroups.com...
>I have a VB application in Excel (in Office 2007).
> If an error occurs, and the error is caught and err.clear executes,
> then all is fine.
> If it is not caught, or if I stop the function at this point (with the
> Reset button),
> events no longer trigger event callbacks!
>
> I added a global function that does: Application.EnableEvents = true
> When I run this, in the debugger I see it's already true
> and running it does nothing.
>
> To re-enable events I have to quit Excel and restart (losing my
> breakpoints).
> How do I get events to work again?
>
> thx
> (I tried to add this to a similar message, but after submitting it
> with "reply to author", didn't see my entry. How do I "reply to
> thread"? I'm using
> http://groups.google.com/group/microsoft.public.excel.programming
> ...)

From: ras on
> Fast and dirty way to reset events quickly is...in the Immediate Window...
> Application.EnableEvents = True

As I said in the original bug, when I execute this in a sub, it's
already true and it doesn't cause events to be triggered.
I'm not sure how to run it in the Immediate Window. I've pasted it in
this window and hit return...

> what do you mean if it is not caught?
I just mean if an error occurs where there's no error catching- yes,
this isn't really a problem.
The problem is if I stop debugging instead of letting the code finish
and do the err.clear.
(Running a small sub containing "err.clear" also doesn't get event
callbacks working again.)
thx...


From: Rick Rothstein on
>> Fast and dirty way to reset events quickly is...in the Immediate
>> Window...
>> Application.EnableEvents = True
>
> As I said in the original bug, when I execute this in a sub, it's
> already true and it doesn't cause events to be triggered.
> I'm not sure how to run it in the Immediate Window. I've pasted it in
> this window and hit return...

That should work (as long as the text cursor is still on the line with that
statement in it. You won't see anything visibly, but the next time you run
your code, events should be Enabled again.

>> what do you mean if it is not caught?
> I just mean if an error occurs where there's no error catching- yes,
> this isn't really a problem.
> The problem is if I stop debugging instead of letting the code finish
> and do the err.clear.
> (Running a small sub containing "err.clear" also doesn't get event
> callbacks working again.)

Of course, you should always have an error handler running. If you want to
include the turning on of events coupled with your error clearing macro,
just include this line...

Application.EnableEvents = True

in that macro's code.

--
Rick (MVP - Excel)


From: ras on
It does NOT work.

> Application.EnableEvents = True

This
a) is not disabled by stopping in the middle of running a macro
b) does NOT re-enable events.
If event callbacks stop, I have NO WAY to start them without
restarting Excel.
This is the problem I'm trying to solve.