How to change Categories property of recurring apointment?

  • Thread starter Thread starter deko
  • Start date Start date
D

deko

When attempting to change the Categories property of a recurring
appointment, I get this error:

Error Number -1179631611: This property cannot be changed for a single
instance of a recurring meeting.

So how do I change the Categories property of the object that represents the
series?

In pseudo code, it might look like this:

Dim objItems as Object
Dim olai As Outlook.AppointmentItem
Dim olitms As Outlook.Items
Set objItems = olitms.Restrict(strCriteria)

For Each olai In objItems
If olai.IsRecurring Then
'how to get the series object???
olai.SeriesObject.Categories = strNewCategory '<== pseudo code
Else
olai.Categories = strNewCategory
End if
Next

Thanks in advance.
 
One complication is that I'm trying to do this inside a For Each loop - of
all appointments, including recurrences. I don't know of any way to get the
"parent" or "series" AppointmentItem when I've included recurrences in the
collection, so I get the whole items collection again (within the outer
loop) and this time do not get recurrences. Then I restrict it and loop
through the items looking for the EntryID in question. Then I can change
the Categories property. Seems like a lot of code... but it works.

Dim olai As Outlook.AppointmentItem
For Each olai in objItems

If Len(olai.Categories) > 0 Then 'we want to update the category
lngCid = Nz(DLookup("Cat_ID", "tblEntity", _
"Entity_ID = " & olai.BillingInformation))
strCategoryName = Nz(DLookup("CatName", "tblCategory", _
"Cat_ID = " & lngCid))

If olai.IsRecurring Then
strEntryID = olai.EntryID
Set olRitms = olns.GetDefaultFolder(olFolderCalendar).Items
strFilter = "[BillingInformation] = " & QT & olai.BillingInformation
& QT
Set objRcr = olRitms.Restrict(strFilter)
i = 0
Do While i < objRcr.Count
i = i + 1
If objRcr(i).EntryID = strEntryID Then
'Debug.Print objRcr(i).Subject & ": " & objRcr(i).Categories
objRcr(i).Categories = strCategoryName
objRcr(i).Save
End If
Loop
Else
olai.Categories = strCategoryName
End If

Next
 
Use the AppointmentItem.RecurrenceState property to work only with the
master appointments (olApptMaster or olApptNotRecurring)

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
Use the AppointmentItem.RecurrenceState property to work only with the
master appointments (olApptMaster or olApptNotRecurring)

Much better! Thanks for the tip!

If olai.Categories <> strNewCategoryName Then
If olai.IsRecurring Then
If olai.RecurrenceState = olApptMaster Then
olai.Categories = strNewCategoryName
End If
Else
olai.Categories = strNewCategoryName
End If
End If
 
If TypeOf oItem Is AppointmentItem Then
If oItem.IsRecurring Then
If oItem.RecurrenceState <> olApptMaster Then
Set oItem = oItem.Parent
End If
End If

End If
oItem.Categories = sCat
oItem.Save
 
Back
Top