Platform SDK: CDO 1.2.1

Instance Property (RecurrencePattern Object)

The Instance property returns or sets the instance of the day within the month on which the appointment recurs. Read/write.

Syntax

objRecurPatt.Instance

Data Type

Long

Remarks

The Instance property is used when the AppointmentItem is to recur only once during each recurrence unit, such as the second Wednesday of every month or the first Tuesday of every January. The DayOfWeekMask property must specify exactly one day of the week, and Instance selects the occurrence of that day within the month on which recurrence is enabled. The last occurrence of the day within the month can be represented by the value 5.

Instance is only valid if the value of the RecurrenceType property is CdoRecurTypeMonthlyNth or CdoRecurTypeYearlyNth. When Instance is valid on a newly created RecurrencePattern object, it defaults to the current instance of the current day of the week. For example, if the RecurrencePattern object is created on Wednesday 9 December and RecurrenceType is set to CdoRecurTypeYearlyNth, then DayOfWeekMask defaults to 8 (CdoWednesday), Instance defaults to 2 (the second Wednesday of the month), and MonthOfYear defaults to 12 (December).

Changes you make to properties on a RecurrencePattern object take effect when you call the underlying appointment's Send or Update method.

Example

This code fragment uses the Instance and Interval properties to specify that an appointment is to recur on the third Sunday of every other month:

Dim objAppointment As AppointmentItem 
Dim objRecurrence As RecurrencePattern 
' ... assume AppointmentItem object is valid ... 
Set objAppointment = objAppointments.Add 
With objAppointment 
  .Subject = "Using Instance and Interval with MonthlyNth" 
  .Text = "Creating an appointment and making it recur on the " _ 
          & "3rd Sunday of every other month for one year." 
  .Location = "My office" 
  Set objRecurrence = .GetRecurrencePattern 
  With objRecurrence 
    .RecurrenceType = CdoRecurTypeMonthlyNth 
    .PatternStartDate = Now 
    .PatternEndDate = DateAdd("m", 12, .PatternStartDate) 
    .StartTime = .PatternStartDate ' takes only the time component 
    .EndTime = DateAdd("h", 1, .StartTime) ' 1-hour appointment 
    .DayOfWeekMask = 1 ' CdoSunday 
    .Instance = 3 ' third Sunday of month 
    .Interval = 2 ' every other month 
  End With 
  objAppointment.Update ' must do this for settings to take effect 
End With