ItemChange event

Status
Not open for further replies.

jepp

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Hi.
I have a problem with events NewInspector and ItemChange.
In first event a copy, of contact being opened, is created. This copy is then moved to backup folder.
The second event is triggered right after the first one, probably because of a copy created in first event.
But, if I run first event step by step, then the second event ItemChange is not triggered.

I don't understand what is triggering the ItemChange after NewInspector event. Is it a copy of the contact?
And why the ItemChange is not triggered if i ran the code step by step?

Thanks. George
 

jepp

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
I also figure it out, that ItemChange goes to endless loop. Is it posible because of item.copy - item.move?
 

jepp

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Can you post the code you are using? Are you moving the copy or the original item? If you move the original, you are changing it.

Set the copy to a new item then move the copy.
Hi Diane. I am moving the copy of the original item. I figure it out, that event is triggered because of moving the copy to the destination folder. That folder is not monitored for changes. But ItemChange fires anyway and it cannot find copied item. When setting object, error "An object could not be found" comes up.
 

jepp

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Can you post the code you are using? Are you moving the copy or the original item? If you move the original, you are changing it.

Set the copy to a new item then move the copy.
Can I end sub in a event, that ItemChange cannot find item, because it has moved?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
You can Exit sub or use an error handler to jump out when it hits an error - on error resume next should work.

are you using code like this to create the copy and move it? I was thinking this wouldn't trigger itemchange -but now that you've said it was because it was looking for the copy, I'm not so sure.
Set objCopy = Item.Copy
objCopy.Move objDestFolder
 

jepp

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
You can Exit sub or use an error handler to jump out when it hits an error - on error resume next should work.

are you using code like this to create the copy and move it? I was thinking this wouldn't trigger itemchange -but now that you've said it was because it was looking for the copy, I'm not so sure.
Set objCopy = Item.Copy
objCopy.Move objDestFolder
I am using code like in your example. The weirdest thing is, that the event isn't fired, if I have a break on NewInspector event, and then go thrue the code step by step. ItemChange event is only fired when code runs uninterupted.
 

jepp

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Diane, I have added error handler and just stop sub. Everythink seems to work as it should. But I don't like it. And I am not 100% sure that its over.
I still can't get it, why this event is triggerd by copy/move. And why code works step by step.

Thank you for your help. George.
 

jepp

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
I see now, that on every error I also have to call ThisOutlookSession.Initialize_Handler
Can this be a problem in heavy usage of Outlook?
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Michael might know (he's the resident VBA expert - i only pretend to play one on tv lol) - but after an error, it will need to re-initialize the handler. If you don't copy the item, does it error and reinitialize?
 

jepp

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
Michael might know (he's the resident VBA expert - i only pretend to play one on tv lol) - but after an error, it will need to re-initialize the handler. If you don't copy the item, does it error and reinitialize?
Diane, you are correct. There is no error if I dont copy an item.
 

jepp

Member
Outlook version
Outlook 2010 32 bit
Email Account
POP3
I have just implemented new boolean variable.
Variable is set True in newInspector event, when the item.copy happens.
When ItemChange triggers (right after newInspector), this variable ends sub. No need for calling Application_Startup().
 
Status
Not open for further replies.
Top