PC Review
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Triggering code when a new all-day event is entered
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Triggering code when a new all-day event is entered
![]() |
Triggering code when a new all-day event is entered |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
Hello,
I was hoping someone could help me by telling me how I can get Outlook to execute code whenever a new all-day event is entered. I've been snooping around and can't quite figure it out. I've found various articles that say to: 1. Declare an object variable WithEvents in the ThisOutlookSession module. 2. Initialize the declared object in the Application_Startup procedure. 3. Write code in the ThisOutlookSession module to respond to the declared object's events. My problem is with the syntax of each of those things. If it's not too much trouble could someone provide me with an example of what code I'd actually have to use for each of those three things in order to fire an event whenever a new all-day event is entered? That would be greatly appreciated! Thanks in advance. James |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Hi James,
this little sample executes if an Item is added to the default calendar: '<DieseOutlookSitzung> Private WithEvents Items As Outlook.Items Public Sub Application_Startup() Dim oFld As Outlook.MAPIFolder Set oFld = Application.Session.GetDefaultFolder(olFolderCalendar) If Not oFld Is Nothing Then Set Items = oFld.Items End If End Sub Private Sub Items_ItemAdd(ByVal Item As Object) Dim oAppt As Outlook.AppointmentItem If TypeOf Item Is Outlook.AppointmentItem Then Set oAppt = Item If oAppt.AllDayEvent Then ' here your code goes End If End If End Sub '</DieseOutlookSitzung> -- Viele Grüße Michael Bauer "James Martin" <noreply@noreply.com> wrote in message news:10oq4q3aj8hq823@corp.supernews.com... > Hello, > > I was hoping someone could help me by telling me how I can get Outlook to > execute code whenever a new all-day event is entered. I've been snooping > around and can't quite figure it out. I've found various articles that say > to: > > 1. Declare an object variable WithEvents in the ThisOutlookSession module. > > 2. Initialize the declared object in the Application_Startup procedure. > > 3. Write code in the ThisOutlookSession module to respond to the declared > object's events. > > My problem is with the syntax of each of those things. If it's not too much > trouble could someone provide me with an example of what code I'd actually > have to use for each of those three things in order to fire an event > whenever a new all-day event is entered? > > That would be greatly appreciated! > > Thanks in advance. > > James > > |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Hi Miachael,
That's perfect! Thanks a ton for the help. You've saved me hours of frustration! James "Michael Bauer" <mib00@t-online.de> wrote in message news:eaa$agKxEHA.2624@TK2MSFTNGP11.phx.gbl... > Hi James, > > this little sample executes if an Item is added to the default calendar: > > '<DieseOutlookSitzung> > Private WithEvents Items As Outlook.Items > > Public Sub Application_Startup() > Dim oFld As Outlook.MAPIFolder > Set oFld = Application.Session.GetDefaultFolder(olFolderCalendar) > If Not oFld Is Nothing Then > Set Items = oFld.Items > End If > End Sub > > Private Sub Items_ItemAdd(ByVal Item As Object) > Dim oAppt As Outlook.AppointmentItem > > If TypeOf Item Is Outlook.AppointmentItem Then > Set oAppt = Item > If oAppt.AllDayEvent Then > ' here your code goes > End If > End If > End Sub > '</DieseOutlookSitzung> > > > -- > Viele Grüße > Michael Bauer > > > "James Martin" <noreply@noreply.com> wrote in message > news:10oq4q3aj8hq823@corp.supernews.com... >> Hello, >> >> I was hoping someone could help me by telling me how I can get Outlook > to >> execute code whenever a new all-day event is entered. I've been > snooping >> around and can't quite figure it out. I've found various articles that > say >> to: >> >> 1. Declare an object variable WithEvents in the ThisOutlookSession > module. >> >> 2. Initialize the declared object in the Application_Startup > procedure. >> >> 3. Write code in the ThisOutlookSession module to respond to the > declared >> object's events. >> >> My problem is with the syntax of each of those things. If it's not too > much >> trouble could someone provide me with an example of what code I'd > actually >> have to use for each of those three things in order to fire an event >> whenever a new all-day event is entered? >> >> That would be greatly appreciated! >> >> Thanks in advance. >> >> James >> >> > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

