![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Below is a copy of the code that I'm using to catch when someone updates an
item in their calendar. How would I alter this code to capture an event any appointment in the calendar. Also, if one of the appointments is a recurring appointment how do I capture the update of a single item in the series rather than an update to the entire series? Public WithEvents myItem As AppointmentItem Private Sub Application_Startup() Set myItem = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderCalendar).Items.GetFirst End Sub Private Sub myItem_PropertyChange(ByVal Name As String) MsgBox "The " & Name & " property changed." End Sub |
Ads |
#2
|
|||
|
|||
![]()
That event you're handling won't catch a lot of changes. It also will fail
to work after a while since the myItem object will be out of scope once Application_Startup() finishes and the garbage collector will remove that reference and its events. Always declare an object variable at a class level to keep it alive and therefore keep the events alive. You can handle the events for the Items collection of the Calendar folder. Declare that Items collection at class level and then handle the ItemAdd, ItemChange and ItemRemove events. For recurring events you have to get the master appointment, after testing IsRecurring on the item. If it is recurring then use GetRecurrencePattern to get at RecurrencePattern.Parent to get the master appointment. Never access the RecurrencePattern unless IsRecurring is true, it will make the non-recurring item recurring. Once you have the master appointment you can see if there are any changes to individual occurrences by checking the RecurrencePattern.Exceptions collection, which has all modified and deleted occurrences. -- 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 "kalukaley" wrote in message ... Below is a copy of the code that I'm using to catch when someone updates an item in their calendar. How would I alter this code to capture an event any appointment in the calendar. Also, if one of the appointments is a recurring appointment how do I capture the update of a single item in the series rather than an update to the entire series? Public WithEvents myItem As AppointmentItem Private Sub Application_Startup() Set myItem = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderCalendar).Items.GetFirst End Sub Private Sub myItem_PropertyChange(ByVal Name As String) MsgBox "The " & Name & " property changed." End Sub |
#3
|
|||
|
|||
![]()
I'm still waiting for my Outlook Programming book to arrive so, I'm relying
on online samples. HANDLE ITEMS COLLECTION AT CLASS LEVEL ----------------------------------------------------- I took this to mean that I should use the class Module i've looked at many of the MSDN examples and they say to declare my "Initialize_handler" function in a class module along with the handlers. They say to call Initialize_handler method before events can be handled. I tried calling it from "Application_Startup()" in "ThisOutlookSession" but I just get the message Sub or Fucntion not defined. ------------------------------------------------------------------------------- Code from class Module Note: I really only threw in a msgbox to make sure the method was being called. I'm not going to bother writing extra code, if I can't make sure the method is being called. ------------------------------------------------------------------------------- Public WithEvents CalItems As Outlook.items Public Sub Initialize_handler() Set CalItems = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderCalendar).items MsgBox "I'm here" End Sub ------------------------------------------------------------- Code from "ThisOutlookSession" ------------------------------------------------------------- Private Sub Application_Startup() Initialize_handler End Sub "Ken Slovak - [MVP - Outlook]" wrote: That event you're handling won't catch a lot of changes. It also will fail to work after a while since the myItem object will be out of scope once Application_Startup() finishes and the garbage collector will remove that reference and its events. Always declare an object variable at a class level to keep it alive and therefore keep the events alive. You can handle the events for the Items collection of the Calendar folder. Declare that Items collection at class level and then handle the ItemAdd, ItemChange and ItemRemove events. For recurring events you have to get the master appointment, after testing IsRecurring on the item. If it is recurring then use GetRecurrencePattern to get at RecurrencePattern.Parent to get the master appointment. Never access the RecurrencePattern unless IsRecurring is true, it will make the non-recurring item recurring. Once you have the master appointment you can see if there are any changes to individual occurrences by checking the RecurrencePattern.Exceptions collection, which has all modified and deleted occurrences. -- 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 "kalukaley" wrote in message ... Below is a copy of the code that I'm using to catch when someone updates an item in their calendar. How would I alter this code to capture an event any appointment in the calendar. Also, if one of the appointments is a recurring appointment how do I capture the update of a single item in the series rather than an update to the entire series? Public WithEvents myItem As AppointmentItem Private Sub Application_Startup() Set myItem = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderCalendar).Items.GetFirst End Sub Private Sub myItem_PropertyChange(ByVal Name As String) MsgBox "The " & Name & " property changed." End Sub |
#4
|
|||
|
|||
![]()
If the event handler and init code is in a class module you'd have to
instantiate an instance of that class in the Application_Startup() code, and the class would have to retain scope after Application_Startup() ended. A class has no existence until an instance of it is instantiated. Let's say the class module was named myClass. Then to use it you'd do this in ThisOutlookSession: Dim classHandler As New myClass Then in Application_Startup() the call would look like this: classHandler.Initialize_handler A simpler approach would be to move all of your class code into the ThisOutlookSession class module. The WithEvents declarations would be at the top of the module, above any procedures. Initialize_handler() would be in ThisOutlookSession also and could be Private if you want, it wouldn't have to be Public. In that case the call to the Initialize_handler would look like it does now. -- 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 "kalukaley" wrote in message ... I'm still waiting for my Outlook Programming book to arrive so, I'm relying on online samples. HANDLE ITEMS COLLECTION AT CLASS LEVEL ----------------------------------------------------- I took this to mean that I should use the class Module i've looked at many of the MSDN examples and they say to declare my "Initialize_handler" function in a class module along with the handlers. They say to call Initialize_handler method before events can be handled. I tried calling it from "Application_Startup()" in "ThisOutlookSession" but I just get the message Sub or Fucntion not defined. ------------------------------------------------------------------------------- Code from class Module Note: I really only threw in a msgbox to make sure the method was being called. I'm not going to bother writing extra code, if I can't make sure the method is being called. ------------------------------------------------------------------------------- Public WithEvents CalItems As Outlook.items Public Sub Initialize_handler() Set CalItems = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderCalendar).items MsgBox "I'm here" End Sub ------------------------------------------------------------- Code from "ThisOutlookSession" ------------------------------------------------------------- Private Sub Application_Startup() Initialize_handler End Sub |
#5
|
|||
|
|||
![]()
Almost There. I noticed that I didn't include the actual hanlder. The
Inialize_handler is now being called (message box is working). However, the ItemChange Event doesn't appear to be called. I have a recurring Appointment in my calendar. as a simple test I change the duration or start time ( or any other thing ) in the appointment then save it. At this point I'm expecting a pop-up from my eventhandler ... but nothing happens. P.S. The future of this code is more than just dopey pop-ups ![]() -------------------------------------------------------------------- From CLASS MODULE ------------------------------------------------------------------- Public WithEvents CalItems As Outlook.items Public Sub Initialize_handler() Set CalItems = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderCalendar).items MsgBox "I'm here" End Sub Public Sub CalItems_ItemChange(ByVal Item As Object) MsgBox "now I am here" End Sub ----------------------------------------------------------------------- From ThisOutLookSession ----------------------------------------------------------------------- Dim classHandler As New Class1 Private Sub Application_Startup() classHandler.Initialize_handler End Sub "kalukaley" wrote: Below is a copy of the code that I'm using to catch when someone updates an item in their calendar. How would I alter this code to capture an event any appointment in the calendar. Also, if one of the appointments is a recurring appointment how do I capture the update of a single item in the series rather than an update to the entire series? Public WithEvents myItem As AppointmentItem Private Sub Application_Startup() Set myItem = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderCalendar).Items.GetFirst End Sub Private Sub myItem_PropertyChange(ByVal Name As String) MsgBox "The " & Name & " property changed." End Sub |
#6
|
|||
|
|||
![]()
Does the event fire if you modify a non-recurring appointment?
-- 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 "kalukaley" wrote in message ... Almost There. I noticed that I didn't include the actual hanlder. The Inialize_handler is now being called (message box is working). However, the ItemChange Event doesn't appear to be called. I have a recurring Appointment in my calendar. as a simple test I change the duration or start time ( or any other thing ) in the appointment then save it. At this point I'm expecting a pop-up from my eventhandler ... but nothing happens. P.S. The future of this code is more than just dopey pop-ups ![]() -------------------------------------------------------------------- From CLASS MODULE ------------------------------------------------------------------- Public WithEvents CalItems As Outlook.items Public Sub Initialize_handler() Set CalItems = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderCalendar).items MsgBox "I'm here" End Sub Public Sub CalItems_ItemChange(ByVal Item As Object) MsgBox "now I am here" End Sub ----------------------------------------------------------------------- From ThisOutLookSession ----------------------------------------------------------------------- Dim classHandler As New Class1 Private Sub Application_Startup() classHandler.Initialize_handler End Sub |
#7
|
|||
|
|||
![]()
Thanks Ken, turns out that I left out a simple step. I needed to close out
of outlook and get back in; all the tidbits you gave me were right on target. Do you have a website. I'd like to go through your information. There's a lot of information out there, but a lot of it assumes a certain level of knowledge that tyro's like me simply don't have. Thanks again. "Ken Slovak - [MVP - Outlook]" wrote: Does the event fire if you modify a non-recurring appointment? -- 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 "kalukaley" wrote in message ... Almost There. I noticed that I didn't include the actual hanlder. The Inialize_handler is now being called (message box is working). However, the ItemChange Event doesn't appear to be called. I have a recurring Appointment in my calendar. as a simple test I change the duration or start time ( or any other thing ) in the appointment then save it. At this point I'm expecting a pop-up from my eventhandler ... but nothing happens. P.S. The future of this code is more than just dopey pop-ups ![]() -------------------------------------------------------------------- From CLASS MODULE ------------------------------------------------------------------- Public WithEvents CalItems As Outlook.items Public Sub Initialize_handler() Set CalItems = Application.GetNamespace("MAPI").GetDefaultFolder( olFolderCalendar).items MsgBox "I'm here" End Sub Public Sub CalItems_ItemChange(ByVal Item As Object) MsgBox "now I am here" End Sub ----------------------------------------------------------------------- From ThisOutLookSession ----------------------------------------------------------------------- Dim classHandler As New Class1 Private Sub Application_Startup() classHandler.Initialize_handler End Sub |
#8
|
|||
|
|||
![]()
My Web site is referenced in my signature.
The best reference for Outlook coding is at www.outlookcode.com. That site has tons of sample code and articles about developing for Outlook. -- 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 "kalukaley" wrote in message ... Thanks Ken, turns out that I left out a simple step. I needed to close out of outlook and get back in; all the tidbits you gave me were right on target. Do you have a website. I'd like to go through your information. There's a lot of information out there, but a lot of it assumes a certain level of knowledge that tyro's like me simply don't have. Thanks again. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
"Recurring events" glitch when categorzing events in Outlook Cal 2 | dwarfdog | Outlook - Calandaring | 1 | November 29th 07 09:55 PM |
single events change to recurring events without a prompt. | TPDavidson | Outlook - Calandaring | 0 | February 12th 07 04:48 AM |
Getting rid of duplicate events vs. Recurring events | AK | Outlook - Calandaring | 1 | September 29th 06 01:23 PM |
1-Day Events randomly turn into 2-Day Events | MJWUSTL | Outlook - Calandaring | 1 | August 16th 06 05:25 PM |
Item open events and double click events in exchange client extension. | Fanxa | Add-ins for Outlook | 1 | August 9th 06 08:18 AM |