Change Category when Task is marked Completed

Last reviewed on March 9, 2013

Use this code to remove all categories and set the category to "Completed" when a Task is marked Complete.

You need to use two (or more) If statements with this code. If you check just for Complete = True, it will run forever. In this code sample, I'm checking the Category for "Completed" (and skipping Recurring tasks). If the category is not marked Completed, the code removes all categories and sets the Category to Completed. It saves and then opens the task.

This macro needs to go into ThisOutlookSession. To test the macro, click in Initialize_handler then click the Run button.

See How to use the VBA Editor if you don't know how to use macros.


Public WithEvents OlItems As Outlook.Items

Public Sub Initialize_handler()
    Set OlItems = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderTasks).Items
End Sub

Private Sub OlItems_ItemChange(ByVal Item As Object)
      
If Item.Complete = True And Item.IsRecurring = False Then

If InStr(1, Item.Categories, "Completed") = False Then

With Item
        .Categories = ""
        .Categories = "Completed"
        .Save
        .Display
End With
End If
End If

End Sub

Written by

Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999 and involved in IT support since 1985, Diane is the author of several books and video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.