VBOffice

Automatically Categorize a New Appointment

For users of smartphones, for instance, that don't support categories see how to categorize every new appointment.

Last modified: 2009/09/23 | Accessed: 70.079  | #76
◀ Previous sample Next sample ▶
OLKeeper OLKeeper
OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or e-mails.

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 certain category to any new appointment if it's marked private, or vice versa, mark an appointment private if a certain category is assigned. You just need to replace the category name Sample by any name of your choice.


tip  How to add macros to 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)
  Dim Appt As Outlook.AppointmentItem
  Dim CategoryName as String

  CategoryName = "Sample"

  If TypeOf Item Is Outlook.AppointmentItem Then
    Set Appt = Item
    If Appt.Sensitivity = olPrivate Then
      If Appt.Categories = "" Then
        Appt.Categories = CategoryName
        Appt.Save
      End If
    ElseIf InStr(1, Appt.Categories, CategoryName, vbTextCompare) Then
      Appt.Sensitivity = olPrivate
      Appt.Save
    End If
  End If
End Su
Reporter Reporter
VBOffice Reporter is an easy to use tool for data analysis and reporting in Outlook. A single click, for instance, allows you to see the number of hours planned for meetings the next month.
email  Send a message