If you want to replace the color category of an Outlook item, you’ll need to remove the original one as a new category is assigned. Thus, in this article, we will teach you how to automate this via VBA.
The primary reason why we make use of color categories in Outlook is to better classify and manage your Outlook items. Plus, Outlook permits us to assign one or more color categories to one item. However, too many categories assigned to a single item may sometimes clutter up your classification rules. Therefore, many users want to replace the color category instead of overlaying categories. Here we will expose an effective way to you.

Replace the Color Category of an Outlook Item
- At the very outset, launch your Outlook application.
- Then switch to “Developer” tab and click the “Visual Basic” button or press “Alt + F11” key shortcuts.
- Next you will enter the “Microsoft Visual Basic for Applications” window.
- At this point, you should double click on the “ThisOutlookSession” project on the left side to open it.
- Subsequently, copy the following VBA codes into this project window.
Public WithEvents objExplorer As Outlook.Explorer
Public WithEvents objInspectors As Outlook.Inspectors
'Take Mailitem as an example
Public WithEvents objMail As Outlook.MailItem
Private Sub Application_Startup()
Set objExplorer = Outlook.Application.ActiveExplorer
Set objInspectors = Outlook.Application.Inspectors
End Sub
Private Sub objExplorer_Activate()
On Error Resume Next
Set objMail = objExplorer.Selection.Item(1)
End Sub
Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
Set objMail = Inspector.CurrentItem
End Sub
Private Sub objMail_PropertyChange(ByVal Name As String)
Dim strSpecificCategory As String
Dim strCategories As String
Dim varArray As Variant
Dim i As Long
If Name = "Categories" Then
strCategories = objMail.Categories
varArray = Split(objMail.Categories, ",")
If UBound(varArray) >= 1 Then
'If want to get a confirmation before removing the original category
'Add the following lines
'Dim strPrompt As String
'Dim nResponse As Integer
'strPrompt = "Do you want to remove the original color category?"
'nResponse = MsgBox(strPrompt, vbQuestion + vbYesNo, "Color Category Assignment")
'If nResponse = vbYes Then
For i = 0 To UBound(varArray)
'Remove the previous color categories
varArray(1) = ""
'Rebuild the categories
objMail.Categories = Join(varArray, ",")
Exit Sub
Next i
'End If
End If
End If
End Sub
- After that, you should assign a digital certificate to this new macro.
- Later you need check your Outlook macro settings to ensure signed macros are enabled.
- Eventually you should restart Outlook to activate the new VBA project.
- From now on, every time you assign a new category to an item, the previous one will be automatically removed.
Handle Nettlesome Outlook Issues
As Outlook is prone to error and corruption, you will encounter various issues in your Outlook. Therefore, you should make sufficient precautious. For instance, it is advisable to make regular backups for your PST file. Moreover, you ought to get hold of a powerful PST fix tool, such as DataNumen Outlook Repair.
Author Introduction:
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including recover Sql Server and outlook repair software products. For more information visit www.datanumen.com
