I want to use a vba macro to do what is discussed in this thread http://www.experts-exchange.com/Software/Office_Productivity/Groupware/Outlook/Q_25072154.html?sfQueryTermInfo=1+10+30+assign+calendar+categori+item+outlook
The calendar items that I want to change (actually add a category to) are already assigned to a category that always contain certain text. Aditionally, part of the subject line for each of those items also always contains the same text.
For example the calendar items always are named "NRVV-xxxxxxxx", where the "x" can be variable text, but the category name always starts with "NRVV". Likewise, the Subject line also always contains "Bkg#" somewhere in the text string.
How can I automatically search the calendar items and add them to another category if they contain one of the text blocks.
Here is the code I currently have in ThisOutlookSession, but it doesn't change (add) the category to the calendar items like I want it to. I'd like them to all be part of the "NRVV" category that is in the Master Cetegory list.
Dim WithEvents olkCalendar As Outlook.Items
Private Sub Application_Quit()
Set olkCalendar = Nothing
Private Sub Application_Startup()
Set olkCalendar = Session.GetDefaultFolder(olFolderCalendar).Items
Private Sub olkCalendar_ItemAdd(ByVal Item As Object)
Dim olkAppt As Outlook.AppointmentItem
Set olkAppt = Item
'Here are a couple of examples of category rules you can construct to assign a category'
'If the phrase Project X is in the item subject, then assign it to a category called Projects'
If InStr(1, olkAppt.Subject, "NRVV") Then AddCategory olkAppt, "NRVV"
'If you are not the meeting organizer, then assign it to a category of Meetings'
'If olkAppt.Organizer <> Session.CurrentUser Then AddCategory olkAppt, "Meetings"
Private Sub AddCategory(olkItem As Outlook.AppointmentItem, strCategory As String)
If olkItem.Categories = "" Then
olkItem.Categories = strCategory
olkItem.Categories = olkItem.Categories & "," & strCategory