The VBScripts on this page will export a list of your categories for backup and importing. If you have more than one data file, it will only export or import to the default data file. If a category already exists when you import, it is skipped.
I have VBA macros to export and import Categories (including one that gets or adds categories to every account in your profile) but it is a little too much work for one time use (unless you need the categories from all mailboxes) since you need to change Outlook's macro security settings. Using PowerShell is easier as you don't need to change Outlook's security settings to use it. VBScript doesn't need the security settings changed, is a one-click solution and can be used in a logon script.
Export Category names and colors
This code sample will write the category names, color code, and shortcut to a text file. You can delete the categories at the same time.
The exported list will look like this:
Newsletters,5,0 Business,2,0 Past,24,0 Accepted,3,0 EMO,10,0
To use, copy and paste the code sample into Notepad, change the file path to the desired location for the exported category list then save it with the vbs extension.
Double click to run the VBA file.
Dim objOutlook, objNS, objFolder Set objOutlook = CreateObject("Outlook.Application") Set objNS = objOutlook.GetNamespace("MAPI") Dim objCat Dim strOutput ' Get Categories If objNS.Categories.Count > 0 Then For Each objCat In objNS.Categories strOutput = strOutput & objCat.Name & ", " _ & objCat.Color & ", " & objCat.ShortcutKey & vbCrLf ' to remove categories as you make the list ' uncomment this line 'objNS.Categories.Remove (objCat.CategoryID) Next End If Set objFSO=CreateObject("Scripting.FileSystemObject") ' Provide file path outFile="D:\Documents\categories.txt" Set objFile = objFSO.CreateTextFile(outFile,True) objFile.WriteLine strOutput objFile.Close
Import the Category names and colors
If you have a list of category names and colors, you can use this script to import them.
If you don't have an exported list, you can create one in Excel. You'll need three columns in each row (but no header row):
- Category name
- Color index (from 1 -25, see table below)
- Shortcut index (0 for no shortcut, 1 - 11 for the shortcuts).
When finished, save it as a CSV file. Before importing, open it in Notepad to verify that the category names or index numbers are not wrapped in quotes. If there are quotes, use Search and Replace to remove them.
Your finished list will look like this:
Newsletters,5,0 Business,2,0 Past,24,0 Accepted,3,0 EMO,10,0
Open a new file in Notepad, paste the code into it then change the file path to point to the text file you want to Import. Save it with the .vbs extension.
To run it: simply double click on the .vbs file you just saved. The categories will be added to the list. If the category names already exists, the entry is skipped.
Dim objOutlook, objNamespace, objFolder Set objOutlook = CreateObject("Outlook.Application") Set objNS = objOutlook.GetNamespace("MAPI") Dim get_cat Dim splitCategory Set objFileToRead = CreateObject("Scripting.FileSystemObject").OpenTextFile("D:\Documents\categories.txt",1) do while not objFileToRead.AtEndOfStream get_cat= objFileToRead.ReadLine() splitCategory = Split(get_cat, ",") On Error Resume Next ' use text file, no quotes around category name objNS.Categories.Add splitCategory(0), splitCategory(1), splitCategory(2) loop objFileToRead.Close Set objFileToRead = Nothing
Category Colors and Shortcut Keys
The following is a list of the category colors and their index number. Outlook 365 has brighter colors and some new color names, which are noted in the table.
Color | Index | Color | Index |
---|---|---|---|
Red | 1 | New: Gray Old: Dark Gray | 14 |
Orange | 2 | New: Dark Gray Old: Black | 15 |
Peach | 3 | Dark Red | 16 |
Yellow | 4 | Dark Orange | 17 |
New: Light Green Old: Green | 5 | New: Brown Old: Dark Peach | 18 |
New: Light Teal Old: Teal | 6 | New: Gold Old: Dark Yellow | 19 |
New: Lime Green Old: Olive | 7 | Dark Green | 20 |
Blue | 8 | New: Teal Old: Dark Teal | 21 |
New: Lavender Old: Purple | 9 | New: Green Old: Dark Olive | 22 |
New: Magenta Old: Maroon | 10 | New: Navy Blue Old: Dark Blue | 23 |
New: Light Gray Old: Steel | 11 | Dark Purple | 24 |
New: Steel Old: Dark Steel | 12 | New: Dark Pink Old: Dark Maroon | 25 |
New: Warm Gray Old: Gray | 13 |
Shortcut | Index | Shortcut | Index |
---|---|---|---|
Ctrl+F2 | 1 | Ctrl+F8 | 7 |
Ctrl+F3 | 2 | Ctrl+F9 | 8 |
Ctrl+F4 | 3 | Ctrl+F10 | 9 |
Ctrl+F5 | 4 | Ctrl+F11 | 10 |
Ctrl+F6 | 5 | Ctrl+F12 | 11 |
Ctrl+F7 | 6 |
More Information
See these article for other methods to import or export categories:
Create a List of Color Categories to Merge or Restore
Print a list of Outlook Categories and their Colors
Use PowerShell to Export and Import Categories
Great content! Keep up the good work!