AppointmentItem.BeforeDelete Event

Status
Not open for further replies.
K

Kevin

I am trying to create code in VBA to trigger an event anytime that an

AppointmentItem in my calendar is deleted so that I can do some processing.

The BeforeDelete event seems to be the one, but I am having trouble figuring

out exactly how I would link the event to the the Calendar. In VBA, the only

events that I see are the ones assocated with the Application. How do I

implement the events for stuff happening in the Calendar?

Thanks!

Kevin
 
S

Sue Mosher [MVP]

Outlook version?

Sue Mosher

"Kevin" <Kevin> wrote in message

news:D6860266-33AA-4F1D-97BA-FB80EC2DD6DE@microsoft.com...
> I am trying to create code in VBA to trigger an event anytime that an
> AppointmentItem in my calendar is deleted so that I can do some
> processing.
> The BeforeDelete event seems to be the one, but I am having trouble
> figuring
> out exactly how I would link the event to the the Calendar. In VBA, the
> only
> events that I see are the ones assocated with the Application. How do I
> implement the events for stuff happening in the Calendar?

> Thanks!

> Kevin
 
K

Kevin

Sorry! 2007.

"Sue Mosher [MVP]" wrote:


> Outlook version?

> > Sue Mosher
> > >

> "Kevin" <Kevin> wrote in message
> news:D6860266-33AA-4F1D-97BA-FB80EC2DD6DE@microsoft.com...
> >I am trying to create code in VBA to trigger an event anytime that an
> > AppointmentItem in my calendar is deleted so that I can do some
> > processing.
> > The BeforeDelete event seems to be the one, but I am having trouble
> > figuring
> > out exactly how I would link the event to the the Calendar. In VBA, the
> > only
> > events that I see are the ones assocated with the Application. How do I
> > implement the events for stuff happening in the Calendar?
> > Thanks!
> > Kevin


>
 
S

Sue Mosher [MVP]

The event you should use is Folder.BeforeItemMove; see its topic in Help or

in the Outlook Developer Reference at

http://msdn.microsoft.com/en-us/library/bb147840.aspx. To see that event in

action, put the following code in the built-in ThisOutlookSession module and

either restart Outlook or run the Application_Startup procedure:

Dim WithEvents objCalFolder As Outlook.Folder

Dim objDelFolder As Outlook.Folder

Private Sub Application_Startup()

Set objCalFolder =

Application.Session.GetDefaultFolder(olFolderCalendar)

Set objDelFolder =

Application.Session.GetDefaultFolder(olFolderDeletedItems)

End Sub

Private Sub objCalFolder_BeforeItemMove(ByVal Item As Object, ByVal

MoveTo As MAPIFolder, Cancel As Boolean)

If MoveTo Is Nothing Then

Debug.Print Item.Subject & " was hard deleted"

ElseIf MoveTo = objDelFolder Then

Debug.Print Item.Subject & " was moved to Deleted Items"

End If

End Sub

Sue Mosher

"Kevin" <Kevin> wrote in message

news:B97DAFF8-CB12-451B-B513-BE2BBA4994FF@microsoft.com...
> Sorry! 2007.
>
> > >I am trying to create code in VBA to trigger an event anytime that an
> > > AppointmentItem in my calendar is deleted so that I can do some
> > > processing.
> > > The BeforeDelete event seems to be the one, but I am having trouble
> > > figuring
> > > out exactly how I would link the event to the the Calendar. In VBA, the
> > > only
> > > events that I see are the ones assocated with the Application. How do I
> > > implement the events for stuff happening in the Calendar?
> >> > Thanks!
> >> > Kevin

>

>
>>
 
S

Sue Mosher [MVP]

Sorry about the bad line wrapping. Those Set statements can have an

underscore

line break in them to make them display better in this newsgroup:

Set objCalFolder = _

Application.Session.GetDefaultFolder(olFolderCalendar)

Set objDelFolder = _

Application.Session.GetDefaultFolder(olFolderDeletedItems)

"Sue Mosher [MVP]" <suemvp@turtleflock.com> wrote in message

news:Ox17tROAKHA.3556@TK2MSFTNGP04.phx.gbl...
> The event you should use is Folder.BeforeItemMove; see its topic in Help
> or in the Outlook Developer Reference at
> http://msdn.microsoft.com/en-us/library/bb147840.aspx. To see that event
> in action, put the following code in the built-in ThisOutlookSession
> module and either restart Outlook or run the Application_Startup
> procedure:

> Dim WithEvents objCalFolder As Outlook.Folder
> Dim objDelFolder As Outlook.Folder

> Private Sub Application_Startup()
> Set objCalFolder =
> Application.Session.GetDefaultFolder(olFolderCalendar)
> Set objDelFolder =
> Application.Session.GetDefaultFolder(olFolderDeletedItems)
> End Sub

> Private Sub objCalFolder_BeforeItemMove(ByVal Item As Object, ByVal
> MoveTo As MAPIFolder, Cancel As Boolean)
> If MoveTo Is Nothing Then
> Debug.Print Item.Subject & " was hard deleted"
> ElseIf MoveTo = objDelFolder Then
> Debug.Print Item.Subject & " was moved to Deleted Items"
> End If
> End Sub

> > Sue Mosher
> > >

> "Kevin" <Kevin> wrote in message
> news:B97DAFF8-CB12-451B-B513-BE2BBA4994FF@microsoft.com...
> > Sorry! 2007.
> >
> >> >I am trying to create code in VBA to trigger an event anytime that an
> >> > AppointmentItem in my calendar is deleted so that I can do some
> >> > processing.
> >> > The BeforeDelete event seems to be the one, but I am having trouble
> >> > figuring
> >> > out exactly how I would link the event to the the Calendar. In VBA,
> >> > the
> >> > only
> >> > events that I see are the ones assocated with the Application. How do
> >> > I
> >> > implement the events for stuff happening in the Calendar?
> >>>> > Thanks!
> >>>> > Kevin
> >
>>
>>>


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
PGSystemTester VBA To Change AppointmentItem.BusyStatus From MeetingItem Before Send Using Outlook 0
M programmatically make all Appointmentitem olResource Attendees unsendable Using Outlook 1
E Redemption access AppointmentItem Label from outlook Outlook VBA and Custom Forms 6
N Help in programmatically setting formatting in an AppointmentItem Outlook VBA and Custom Forms 3
P AppointmentItem Receipient's GUID Outlook VBA and Custom Forms 2
H access appointmentItem from ribbon menu Outlook VBA and Custom Forms 1
S delete appointmentitem permanently using redemption Outlook VBA and Custom Forms 2
P Calendar Day View only shows 1 all day event Using Outlook 0
G Event when creating task from mailitem Outlook VBA and Custom Forms 2
diver864 vba for a rule to automatically accept meeting requests with 'vacation' in subject, change to all-day event, change to free, don't send reply Outlook VBA and Custom Forms 1
J Outlook 2010 Outlook/Win7 Client logging Event ID 36887 Using Outlook 0
K Recurring all day annual event Using Outlook 3
P Restore an individual all-day recurring event Using Outlook 2
K VBA BeforeItemMove event create rule to always move to its folder. Outlook VBA and Custom Forms 4
K Working with Explorer.Close event Outlook VBA and Custom Forms 3
F Outlook 2016 call to Stop Timer Event Outlook VBA and Custom Forms 4
D Event ID issues Exchange Server Administration 2
J ItemChange event Outlook VBA and Custom Forms 11
T Outlook 2016 Calendar multiday event display Using Outlook 4
oliv- Treat once an email with the ItemAdd event in a shared mailbox Outlook VBA and Custom Forms 2
M Automatically create event in calendar when task is created Outlook VBA and Custom Forms 1
A UID field in iCal files - unique per-event or per-user or both? Using Outlook 2
D help with Item/Inspector close event Outlook VBA and Custom Forms 1
B on flag message event - create task Outlook VBA and Custom Forms 22
Diane Poremsky Change the All Day Event Default Free/Busy to "Busy" Using Outlook 3
C Calendar - Centering an event in Outlook? Using Outlook 1
J Outlook calendar...How to add an event or appointment without a border around it? Using Outlook 9
J Create Calendar Alert Event form Mail Subject line? Using Outlook 4
S Item Add Event fires intermittently Outlook VBA and Custom Forms 3
R Why is a meeting organizer me and not the creator of the event? Using Outlook 1
V Calendar event acting odd Using Outlook 7
G Capture "forward event" ? Outlook VBA and Custom Forms 11
P Change the Outlook.com "from" address for calendar event invites Using Outlook 9
20 Ton Squirrel Detect Application_Startup event completion Outlook VBA and Custom Forms 1
L Outlook 2007 All Day Event Using Outlook 27
I Event listener for deleted items Using Outlook 6
M Save Attachments Event? Using Outlook 0
Commodore Calendar Folder property is missing - Event 27 Using Outlook 11
G Quit event code - 2007 Using Outlook 3
J Capturing forward event when multiple items are selected Using Outlook 0
P Trying to get 'Calendar Name' to appear like 'Subject' and 'Location' in event Using Outlook 0
G What event happens when you open 2 copies of your inbox? Using Outlook 5
D Adding a participant automatically to a calendar event Using Outlook 1
H Changing Organizer of event (for single to total calendar move; long way ) Exchange Server Administration 4
N Combobox in outlook add ons toolbar not firing event on main window resized Using Outlook 3
D Extracting Location info from All Day Event in mailboxes into webpage Exchange Server Administration 3
H Conflicts with other event in calendar ( outlook 2007 &amp; 2010) Using Outlook 0
B Restoring Deleted Recurring Event AND Notes Using Outlook 8
Q Looking for Outlook 2010 Close Event Id Exchange Server Administration 1
S Outlook Recurring event Using Outlook 1

Similar threads

Top