Last reviewed on December 30, 2013   —  18 Comments

Having a list of categories names and their colors can be helpful when sharing categories with other users, since the color is per-user. Fortunately, MSDN published a sample macro that prints a list of categories and the name of the color assigned. Unfortunately, some of the color names in their macro are not valid. Below is the code from Category.Color Property (Outlook), with the corrected olCategoryColor names.

This macro can display a message box with a list of the category names and colors or print it to the VBA Editor's Immediate window.

To create a list of categories, including their colors and assigned shortcuts that can be restored or merged with the categories in a new profile, see Create a list of color categories and merge or restore the list using VBA.

Use MsgBox strOutput to display a message box or Debug.Print strOutput to print a list to the Immediate window (View > Immediate window or Ctrl+G). You can copy the list from the Immediate window or the MsgBox.

The printout and message box will look like the following:
Create a list of your categories and their assigned colorsUtility: Purple
Bookkeeping: Unknown
Business: Peach
Important: Dark Yellow
Test: Purple
Blue Category: Blue
Federal Holidays: Green
Needs Done: Dark Green
Old Projects that need finished: Dark Olive
Send Message: Yellow
Slipstick: Olive
Follow up soon: Dark Orange

The message box is copyable - click in the text and press Ctrl+C to copy it.

List Category Colors Macro

To use, Open the VBA editor using Alt+F11, right click on the Project folder and choose Insert > Module. Paste this code into the module then click the Run button or press F8. Press Ctrl+G to see the list of category names and colors in the immediate window. Comment out the MsgBox line to use only the Immediate window.

Public Sub ListCategoryNamesandColors()
 Dim objNameSpace As NameSpace
 Dim objCategory As Category
 Dim strOutput As String
 Set objNameSpace = Application.GetNamespace("MAPI")
 If objNameSpace.Categories.Count > 0 Then
 For Each objCategory In objNameSpace.Categories
 strOutput = strOutput & objCategory.Name

 Select Case objCategory.Color
 Case OlCategoryColor.olCategoryColorNone
 strOutput = strOutput & ": No color (white)" & vbCrLf
 Case OlCategoryColor.olCategoryColorBlack
 strOutput = strOutput & ": Black " & vbCrLf
 Case OlCategoryColor.olCategoryColorBlue
 strOutput = strOutput & ": Blue" & vbCrLf
 Case OlCategoryColor.olCategoryColorDarkBlue
 strOutput = strOutput & ": Dark Blue" & vbCrLf
 Case OlCategoryColor.olCategoryColorDarkGreen
 strOutput = strOutput & ": Dark Green" & vbCrLf
 Case OlCategoryColor.olCategoryColorDarkMaroon
 strOutput = strOutput & ": Dark Maroon" & vbCrLf
 Case OlCategoryColor.olCategoryColorDarkOlive
 strOutput = strOutput & ": Dark Olive" & vbCrLf
 Case OlCategoryColor.olCategoryColorDarkOrange
 strOutput = strOutput & ": Dark Orange" & vbCrLf
 Case OlCategoryColor.olCategoryColorDarkPeach
 strOutput = strOutput & ": Dark Peach" & vbCrLf
 Case OlCategoryColor.olCategoryColorDarkPurple
 strOutput = strOutput & ": Dark Purple" & vbCrLf
 Case OlCategoryColor.olCategoryColorDarkRed
 strOutput = strOutput & ": Dark Red" & vbCrLf
 Case OlCategoryColor.olCategoryColorDarkSteel
 strOutput = strOutput & ": Dark Steel" & vbCrLf
 Case OlCategoryColor.olCategoryColorDarkTeal
 strOutput = strOutput & ": Dark Teal" & vbCrLf
 Case OlCategoryColor.olCategoryColorDarkYellow
 strOutput = strOutput & ": Dark Yellow" & vbCrLf
 Case OlCategoryColor.olCategoryColorGray
 strOutput = strOutput & ": Gray" & vbCrLf
 Case OlCategoryColor.olCategoryColorGreen
 strOutput = strOutput & ": Green" & vbCrLf
 Case OlCategoryColor.olCategoryColorMaroon
 strOutput = strOutput & ": Maroon" & vbCrLf
 Case OlCategoryColor.olCategoryColorOlive
 strOutput = strOutput & ": Olive" & vbCrLf
 Case OlCategoryColor.olCategoryColorOrange
 strOutput = strOutput & ": Orange" & vbCrLf
 Case OlCategoryColor.olCategoryColorPeach
 strOutput = strOutput & ": Peach" & vbCrLf
 Case OlCategoryColor.olCategoryColorPurple
 strOutput = strOutput & ": Purple" & vbCrLf
 Case OlCategoryColor.olCategoryColorRed
 strOutput = strOutput & ": Red" & vbCrLf
 Case OlCategoryColor.olCategoryColorSteel
 strOutput = strOutput & ": Steel" & vbCrLf
 Case OlCategoryColor.olCategoryColorTeal
 strOutput = strOutput & ": Teal" & vbCrLf
 Case OlCategoryColor.olCategoryColorYellow
 strOutput = strOutput & ": Yellow" & vbCrLf

 Case Else
 strOutput = strOutput & ": Unknown" & vbCrLf
 End Select
 End If
 ' Display the output string in a msgbox 
 ' or in the immediate window
  MsgBox strOutput
  Debug.Print strOutput
 Set objCategory = Nothing
 Set objNameSpace = Nothing
End Sub

To include the Color Category index number in the listing (useful in other macros), add objCategory.Color to each line, as shown in the sample below. The results will include the index number at the end of the results line: Edit Websites: Dark Steel 12

strOutput = strOutput & ": Dark Steel " & objCategory.Color & vbCrLf


  1. Michael Doncaster says


    I can get this macro to run in the VBA editor, but it will not run from the ribbon.

    I had to change it to a 'public sub' for it to visible in the macro list in the Ribbon customisation pane.

    Any idea why?


    • Diane Poremsky says

      Make sure the msgbox is uncommented near the bottom. It prints to the immediate window by default, which is why it's private. (You could tweak it to print to a new message or text file. )

      Actually... the msgbox is copyable, so you can get a text list without writing to a file.

  2. Tim Chambers says

    Thank you, Diane! The page that referred me to your helpful macro is in the Website field.

    – Tim Chambers 1E4AF729D5CEFFD0
    With apologies to C.S. Lewis: You must picture me alone in front of my Windows computer, day after day, feeling, whenever my mind lifted even for a second from my work, the steady, unrelenting approach of the abominable language that I so earnestly desired not to use. That which I greatly feared had at last come upon me. During a lunch of Rosemary & Olive Oil Triscuits on July 11th, 2012 I gave in, and admitted that Microsoft VBA existed, and opened the VBA editor and ran my very first module: perhaps, that day, the most dejected and reluctant convert in all of cyberspace.

  3. Greg Simonis says

    I copied the code to VBA, deleted the comments at the bottom, and upon running I get an error msg. 'Compile error: User-defined type not defined and it highlights the last part of the second line "Dim 'objNameSpace As Namespace'". The section highlighted I put single quotes around so you see what text was highlighted.

    • Diane Poremsky says

      User-defined type not defined means it thinks there is a custom variable. And that it stops on "Dim objNameSpace As Namespace" means it thinks something in this line is the user-defined type. I don't know why it thinks that, I'm not able to repro it.

  4. Kathie Paintner says

    Just an EA looking for a simple list of all of our categories, opened the VBA editor and pasted the above code, the F8 to run. Then Ctrl+G. Nothing displays in the Immediate Window.

    • Diane Poremsky says

      Do you get any error messages? What is your macro security set to? You should see a dialog box come up with a list of categories as soon as you hit Run and it is repeated in the immediate window.

  5. Dawn Lambert says

    The marco works on the default calendar but I would like to run it on a shared calendar. Where do I enter in the name of the calendar I want to get the categories from?

    Thank you!

    • Diane Poremsky says

      It's a lot more complicated to work with categories in Shared folders and I don't have any code samples that can do it. Sorry.

  6. says

    I need to change the names of the colors (in the existing categories) in order for the entire office to be aware of what each color stands for. Can you provide me with the neccessary steps?

  7. Aaron M. says

    Thank You! For a non-programmer I was able to use your directions to backup my Categories which I rely heavily on. I feel much better now that I have a list of what they are. Thanks again!!

  8. Niels Andersen says

    I imported my contacts into O2010. I have got colours. And all my 1000+ contacts have got individual category NAMES. But I cannot add an existing category name to a new contact, I cannot add a NEW category name, and I cannot see the names in the drop down category list, which shows only the colours. Any ideas, pl?

  9. Steve Glykys says

    Dear Dian, I run the program as advised by I get the message "The Macros in this Project are disabled. Please refer to the on line help or documentation of the host application to determine how to enable macros." Your advise will be very much appreciated. Kind regards Steve

    • Diane PoremskyDiane Poremsky says

      You need to go to File, Options, Trust Center, Trust Center Settings, Macro security and enable macros (lowest setting). Then restart Outlook.

Leave a Reply

Please post long or more complicated questions at OutlookForums by

If the Post Comment button disappears, press your Tab key.