how to diable event handler of the outlook application object

G

Guest

Hi Michael,

thanks for your response. However, it seems like that your method does not
work out.

Because the private Inbox_itemAdd() event handler is always fired after the
" bDisableItemAddEvent=False" is executed in Sub Populate. So the variable
bDisableItemAddEvent still cannot disable the event handler for item added.

Any further advice? Thanks in advance.
 
M

Michael Bauer

Am Mon, 28 Nov 2005 19:47:03 -0800 schrieb lostwings:

If you´d start to realize that the event itself cannot be disabled then I´m
sure you would get the solution yourself :)

You can´t disable the event, but can decide by a simple If..Then..Else,
which part of code within the event shall be executed (if any).

The mechanism is to set a flag (usually a Boolean variable). So if the event
actually is called after the flag is set back to False then you need to move
the "set flag=false" statement into the event procedure. That is, decide
then by checking the flag´s value in the event handler whether the main code
shall be executed or just the flag shall be set to False.
 
G

Guest

hi Michael,

thanks once again for your help. I solve the problem. Instead of using the
flag as boolean, I set its type to integer and its original value to 0.
Every time the contact fold get item from the DB, the flag value increases by
1.

In the event handler part, if the flag is equl to 0, then do the normal
thing (respond to the user add-in item event), otherwise just decreases the
flag by 1.

Now everything works perfectly without any potential confilcts. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top