StartDownloadsServiceSamplesWorkshopsContact DeutschEnglish
Awarded by
Microsoft since 2005:
mvp logo
VBOffice Info
Privacy Policy
Automatically assign a category to any new appointment
Author: Michael BauerHomepage
Date: 23.09.2009Accessed: 21550

If you organize your Outlook items by categories and synchronize with a smartphone that doesn't support categories, either your data organization gets mixed up, or you have to update it manually after any sync. Users who sync the Outlook calendar with the Google calendar via SyncMyCal face the same issue.

This example demonstrates how to assign a given category to any new appointment if it's marked as private (see #1), or vice versa, how to mark an appointment private if a specific category is assigned (see #2).

To get it running, simply copy the code into the module 'ThisOutlookSession' in the VBA environment, replace the sample category by your own category name, and restart Outlook.

Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
  Dim Ns As Outlook.NameSpace

  Set Ns = Application.GetNamespace("MAPI")
  Set Items = Ns.GetDefaultFolder(olFolderCalendar).Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
  If TypeOf Item Is Outlook.AppointmentItem Then
    AddCategoryToPrivateAppointment Item
  End If
End Sub

Private Sub AddCategoryToPrivateAppointment(Appt As Outlook.AppointmentItem)
  ' #1
  If Appt.Sensitivity = olPrivate Then
    If Len(Appt.Categories) = 0 Then
      Appt.Categories = "Private"
    End If
  ' #2
  ElseIf InStr(1, Appt.Categories, "Private", vbTextCompare) Then
    Appt.Sensitivity = olPrivate
  End If
End Sub

ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the ... [more]


Access the master category list in the blink of an eye, share your categories in a network, get a reminder service, and ... [more]


SAM automatically sets the sender, signature, and folder for sent items, for instance based on the recipient ... [more]


OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or ... [more]