A visitor to Slipstick's Outlook Forums needed a macro to toggle a category on and off. If the category is already on the selected message, the macro removes it, otherwise it adds the category.
In order to remove one category when several are applied to a message, you need to split the categories into an array before deleting the category. After the category is deleted from the array, you'll recreate the category string.
This macro sample sets (or removes) four different categories.
Dim StrCat As String Sub MyBlue() StrCat = "Outlook Users" SetCategory End Sub Sub MyBlue2() StrCat = "Macros" SetCategory End Sub Sub myGreen() StrCat = "Business" SetCategory End Sub Sub myOrange() StrCat = "BB" SetCategory End Sub Private Sub SetCategory() Dim Mail As Object Set Mail = Application.ActiveExplorer.Selection.Item(1) Debug.Print Mail.Categories arr = Split(Mail.Categories, ",") If UBound(arr) >= 0 Then ' Check for Category For i = 0 To UBound(arr) If Trim(arr(i)) = StrCat Then ' remove it arr(i) = "" Mail.Categories = Join(arr, ",") ' Category Removed, exit Exit Sub End If Next End If ' Category not found, add it Mail.Categories = StrCat & "," & Mail.Categories End Sub