1

I stepped through this multiple times and it executes without issue.

I set up a watch on "Item.GetReccurrencePattern.PatternEndDate" for the calling procedure (i.e. Application_Reminder event) and the end date does change.

But, when I view my calendar, the additional meetings haven't been created.

And when I open up an occurrence of the meeting, it shows the original end date in the recurrence settings.

Private Sub Application_Reminder(ByVal Item As Object)

If Item.MessageClass <> "IPM.Appointment" Then Exit Sub
Dim myItem As AppointmentItem
Set myItem = Item
Dim DoIt As Boolean

Select Case myItem.ConversationTopic
    Case "TEST"
    DoIt = True
    
    'Will use this for multiple meetings, that's why using select
End Select
    
If DoIt Then ExtendAppt myItem
Set myItem = Nothing
End Sub



Private Sub ExtendAppt(ByRef myApptItem As Outlook.AppointmentItem)

Dim myRecurrPatt As Outlook.RecurrencePattern
Set myRecurrPatt = myApptItem.GetRecurrencePattern

Dim origStart As Date
Dim origEnd As Date
Dim thisWeek As Date
Dim recDate As Long
Dim deltaEnd As Long
Dim newEnd As Date
Dim howMany As Long

origStart = myRecurrPatt.PatternStartDate
origEnd = myRecurrPatt.PatternEndDate

Select Case myRecurrPatt.DayOfWeekMask
Case olFriday
    recDate = vbFriday
Case olMonday
    recDate = vbMonday
Case olTuesday
    recDate = vbTuesday
Case olWednesday
    recDate = vbWednesday
Case olThursday
    recDate = vbThursday
Case olFriday
    recDate = vbFriday
Case olSaturday
    recDate = vbSaturday
Case olSunday
    recDate = vbSunday
Case Else
    'not recurring or error
    Exit Sub
End Select

thisWeek = Date - Weekday(Date, recDate) + 1

deltaEnd = DateDiff("ww", origEnd, thisWeek)

If deltaEnd Mod (2) = 0 Then howMany = 10 Else howMany = 9

newEnd = DateAdd("ww", howMany, thisWeek)

myRecurrPatt.PatternEndDate = newEnd

myApptItem.Save

'Release references to the appointment series
Set myApptItem = Nothing
Set myRecurrPatt = Nothing

End Sub
Community
  • 1
  • 1
CBRF23
  • 1,340
  • 1
  • 16
  • 44
  • Suggestions: Change `myApptItem.Save` to `myApptItem.Display`. Is myApptItem what you think it should be? If changes were made, save manually to see what happens. – niton Jan 28 '21 at 02:07
  • Checked as suggested - confirmed it is the expected appointment. – CBRF23 Feb 02 '21 at 22:15
  • Well, as of this afternoon, it now started throwing an error on the `myApptItem.Save` line - says the object has been closed and no longer exists. Very strange. No change to the code, other than I added, and then commented out, `myApptItem.Display` immediately prior to the save method. Very strange indeed. – CBRF23 Feb 02 '21 at 22:35
  • For possible responders. I get expected results. As suggested by the comment the new behaviour "object has been closed and no longer exists" this may not be directly related to the code. – niton Feb 03 '21 at 14:53
  • Are you trying to update a recurring event? – SendETHToThisAddress Feb 09 '21 at 18:58
  • Yes. Trying to extend the end date of a recurring meeting. – CBRF23 Feb 09 '21 at 20:00
  • FWIW this works just fine with no mods in O365 v2101 so it seems to be a 2013 thing ... – JohnnieL Feb 09 '21 at 20:32
  • That is interesting. We are on 2013 organizationally. I think my wife's computer at home is on 365 - maybe I can test on her computer to see if it works in the newer version. – CBRF23 Feb 10 '21 at 11:40

0 Answers0