View Single Post
  #5  
Old December 5th 08, 03:29 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default code for event: everytime i save an item ...

In Outlook 2007 you can use the Folder.BeforeItemMove() event. That passes
you a reference to the item being moved and the target folder the item is
being moved to. If the target folder is Nothing then the item is being
deleted. There's also a Cancel argument, set that to True in the event
handler and that cancels the deletion.

So you'd declare the Folder object:

Private WithEvents oFolder As Outlook.Folder

That exposes the event handler for BeforeItemMove() in the Declarations
drop-down when oFolder is selected. You'd have to decide which folder to
use, for example if the Calendar folder then your initialization code would
have a line like this:

Set oFolder =
Application.GetNameSpace("MAPI").GetDefaultFolder( olFolderCalendar)

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Patrik" wrote in message
...
where could/should i edit the code if i also want execute some code if the
item is deleted?
(not only new/changed)


Ads