Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How to re-enable events after a VB error in Excel?

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/micro...el.programming
....)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default How to re-enable events after a VB error in Excel?

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" wrote in message
...
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/micro...el.programming
...)


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How to re-enable events after a VB error in Excel?

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...


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default How to re-enable events after a VB error in Excel?

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)


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default How to re-enable events after a VB error in Excel?

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.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default How to re-enable events after a VB error in Excel?

Maybe I need to ask what you mean by "event callbacks"... can you describe
what you mean by this and, perhaps, show us some of your non-working code so
we can see exactly how you are trying to proceed?

--
Rick (MVP - Excel)


"ras" wrote in message
...
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.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Enable Multiple events in the same time rchiuhk Excel Programming 6 October 9th 09 11:22 AM
Help with Enable Macro Error Msg (Excel 2007) DW Excel Programming 10 March 14th 07 06:38 PM
Enable/Disable CommandBar Buttons Based on Events M. Authement Excel Programming 11 October 19th 06 02:46 AM
combobox change event is running when enable events is false tysop Excel Programming 3 January 24th 06 02:16 PM
Enable events John C[_6_] Excel Programming 6 January 24th 04 01:44 PM


All times are GMT +1. The time now is 06:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"