none
Outlook 2010 - recurring appointment RRS feed

  • Question

  • Hello,

    Why is it when i export my calendar, for any recurring events it only shows the very first start date appointment. I want it to export every occurence and the relevant date but the below code doesn't seem to do that... 

      If strLst <> "" Then strLst = Left(strLst, Len(strLst) - 2)
                        'Add a row for each field in the message you want to export
                        excWks.Cells(lngRow, 1) = olkApt.Categories
                        excWks.Cells(lngRow, 2) = olkApt.Subject
                        excWks.Cells(lngRow, 3) = Format(olkApt.Start, "dd/mm/yyyy")
                        excWks.Cells(lngRow, 4) = Format(olkApt.End, "dd/mm/yyyy")
                        excWks.Cells(lngRow, 5) = Format(olkApt.Start, "hh:nn ampm")
                        excWks.Cells(lngRow, 6) = Format(olkApt.End, "hh:nn ampm")
                        excWks.Cells(lngRow, 7) = DateDiff("n", olkApt.Start, olkApt.End) / 60
                        excWks.Cells(lngRow, 7).NumberFormat = "0.00"
                        excWks.Cells(lngRow, 8) = strLst
                        lngRow = lngRow + 1
                        lngCnt = lngCnt + 1
                    End If

    Cheers,

    Cam

    Wednesday, February 3, 2016 11:03 AM

Answers

  • Hello Cameron,

    It is not clear how you get appointment from a folder, but I'd recommend using the Find/FindNext or Restrict methods for getting a subset of items for a day/week/month and then do the same operation for the next day/week/month in a cycle. Read more about these methods in the following series of articles:

    How To: Retrieve Outlook calendar items using Find and FindNext methods

    How To: Use Restrict method in Outlook to get calendar items

    When you work with recurring appointment items, you should release any prior references, obtain new references to the recurring appointment item before you access or modify the item, and release these references as soon as you are finished and have saved the changes. This practice applies to the recurring AppointmentItem object, and any Exception or RecurrencePattern object. To release a reference in Visual Basic for Applications (VBA) or Visual Basic, set that existing object to Nothing. In C#, explicitly release the memory for that object.

    Note that even after you release your reference and attempt to obtain a new reference, if there is still an active reference, held by another add-in or Outlook, to one of the above objects, your new reference will still point to an out-of-date copy of the object. Therefore, it is important that you release your references as soon as you are finished with the recurring appointment.

    Wednesday, February 3, 2016 5:58 PM

All replies

  • For the recurring appointments, you will need to either

    1. make Outlook expand the recurrences for you by using the Items.IncludeRecurrences property (see the example at https://msdn.microsoft.com/en-us/library/office/ff866969.aspx)

    2. Expand the recurrences explicitly by calling AppointmeentItem.GetRecurrentPattern /RecurrentPattern.GetOccurrence.

    Keep in mind that occurrences do not physically exist, Outlook has to create a fake AppointmeentItem object for eaxch occurrence.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!


    Wednesday, February 3, 2016 1:00 PM
  • Hello Cameron,

    It is not clear how you get appointment from a folder, but I'd recommend using the Find/FindNext or Restrict methods for getting a subset of items for a day/week/month and then do the same operation for the next day/week/month in a cycle. Read more about these methods in the following series of articles:

    How To: Retrieve Outlook calendar items using Find and FindNext methods

    How To: Use Restrict method in Outlook to get calendar items

    When you work with recurring appointment items, you should release any prior references, obtain new references to the recurring appointment item before you access or modify the item, and release these references as soon as you are finished and have saved the changes. This practice applies to the recurring AppointmentItem object, and any Exception or RecurrencePattern object. To release a reference in Visual Basic for Applications (VBA) or Visual Basic, set that existing object to Nothing. In C#, explicitly release the memory for that object.

    Note that even after you release your reference and attempt to obtain a new reference, if there is still an active reference, held by another add-in or Outlook, to one of the above objects, your new reference will still point to an out-of-date copy of the object. Therefore, it is important that you release your references as soon as you are finished with the recurring appointment.

    Wednesday, February 3, 2016 5:58 PM