GetRecurrencePattern Method (AppointmentItem Object)

The GetRecurrencePattern method returns a RecurrencePattern object defining the recurrence attributes of an appointment.

Syntax

Set objRecurPatt = objAppointment.GetRecurrencePattern( )

objRecurPatt
On successful return, contains the RecurrencePattern object.
objAppointment
Required. This AppointmentItem object.

Remarks

If the appointment had already been specified as recurring, the GetRecurrencePattern method returns the RecurrencePattern object containing the current recurrence characteristics. If the appointment was previously nonrecurring, it is made recurring and GetRecurrencePattern returns a new RecurrencePattern object populated with the default values indicated in its property descriptions.

The IsRecurring property is set to True when the GetRecurrencePattern method is called.

Note You cannot use GetRecurrencePattern to test whether an appointment is recurring, because it always returns a RecurrencePattern object and forces the appointment to be recurring. Instead, you should test for recurrence using the IsRecurring property.

You can use the ClearRecurrencePattern method to return the appointment to nonrecurring status.

Example

This code fragment makes an appointment recurring and changes its Subject property. It is equally valid for a nonrecurring appointment, an appointment originating a recurring series, and an individual recurrence in that series. If objAppt is nonrecurring before executing this fragment, it becomes the originator of a recurring series. If it is already an originator, doing objOrig.Update is equivalent to doing objAppt.Update.

Dim objAppt, objOrig As AppointmentItem 
  Dim objRecPatt As RecurrencePattern 
  ' objAppt can be solitary, an originator, or a recurrence 
  Set objRecPatt = objAppt.GetRecurrencePattern 
  With objRecPatt 
        ' set recurrence pattern properties as desired 
  End with 
  Set objOrig = objRecPatt.Parent 
  With objOrig 
    .Subject = "New subject for entire recurring series" 
    .Update ' necessary for any changes to take effect 
  End with 
 

Note If objAppt in the preceding fragment is an individual recurrence, its properties are not changed by objOrig.Update. This is because changes you make in the original appointment only affect recurrences instantiated after the update. Because objAppt was already instantiated before the update, its Subject property is not updated when objOrig.Subject is. To avoid this problem, you can refresh objAppt by repeating the Set statement that instantiated it in the first place.