Here, I am trying to clone recurring appointments to a new calendar which has additional userproperties
but I get a
Run-time error '-2147417848(80010108)':
Automation error
The object invoked has disconnected from its clients
error when
1)setting a user property
2)set the recurrencepattern
code follows:
(for my purposes the 1st occurrence of the error (on .userproperties("prop")) is of more importance because I do not know how to handle the exceptions and thus I will clone all appointments (even recurring ones) as one-off appointments.If you do have a way to do as such please comprehend
but I get a
Run-time error '-2147417848(80010108)':
Automation error
The object invoked has disconnected from its clients
error when
1)setting a user property
2)set the recurrencepattern
code follows:
Code:
Private Sub clonecalwithproperties()
Dim primarycalendar As Outlook.Folder
Dim destinationcalendar As Outlook.Folder
Dim sourcecalendar As Outlook.Folder
Dim sourceitems As Outlook.Items
Dim appt As Outlook.AppointmentItem
'Does this have a OOO/WFH custom property set? This is set by a macro on the Meeting Request form
'If Appt.MeetingStatus = olMeeting And Not (Appt.ItemProperties.Item("OOORequest") Is Nothing) Then
Set primarycalendar = Outlook.Application.Session.GetDefaultFolder(olFolderCalendar)
Set sourcecalendar = primarycalendar.Folders("subfolder1")
Set destinationcalendar = primarycalendar.Folders("¸subfolder")
Set sourceitems = sourcecalendar.Items
For Each appt In sourceitems
Dim new_appt As AppointmentItem
'Create appointment for sender's calendar
Set new_appt = destinationcalendar.Items.Add
With new_appt
.Subject = appt.Subject
.BusyStatus = appt.BusyStatus
.ReminderSet = appt.ReminderSet
.Start = appt.Start
.End = appt.End
.AllDayEvent = appt.AllDayEvent
.Body = appt.Body
.UserProperties("customercat") = appt.UserProperties("customercat")
.UserProperties("productcat") = appt.UserProperties("productcat")
.Save
End With
'If recurring meeting, duplicate recurrence pattern for new appointment
Dim RPOrig As RecurrencePattern
Dim RPNew As RecurrencePattern
If appt.IsRecurring Then
Set RPOrig = appt.GetRecurrencePattern
Set RPNew = new_appt.GetRecurrencePattern
RPNew = RPOrig
new_appt.Save
End If
Next
'End If
'Release resources
Set new_appt = Nothing
End Sub
(for my purposes the 1st occurrence of the error (on .userproperties("prop")) is of more importance because I do not know how to handle the exceptions and thus I will clone all appointments (even recurring ones) as one-off appointments.If you do have a way to do as such please comprehend