Many Outlook users depended heavily on the category feature until it was removed. So, it was no big surprise when I started hearing from readers and clients about the loss. Fortunately, you can reclaim the feature. If you want to do so manually, read Reclaim Outlook categories for IMAP accounts. This technique works with any open Outlook item, not just email messages. You can do the same thing with a VBScript procedure, which I find much more efficient than using the manual route. In this article, I’ll review a simple procedure that automates reclaiming categories. I do want to stress that because this feature is no longer supported, the procedure could stop working at any time and without notice.
SEE: 83 Excel tips every user should master (TechRepublic)
The VBScript procedure in Outlook
If you’re familiar with VBA but not VBScript, don’t worry. VBS is a subset of VBA. Even if you’re not familiar with VBA, you shouldn’t have any trouble adding and running this procedure. The sub procedure in Listing A is extremely simple. The only catch is that the Outlook item you are categorizing must be open.
Public Sub SetCategory()
‘Displays category dialog so user can
‘set category to open item.
‘If category is unused, feature will prompt
‘for shortcut key selection.
Dim OLItem As Object
‘Quits procedure if no item is open.
On Error GoTo ErrorHandler
Set OLItem = Application.ActiveInspector.CurrentItem
MsgBox “Please open the item you want to categorize.”, vbOKOnly, “Error”
First, the code creates an Object variable named OLItem and sets it to the active (open) item. You can use this procedure to categorize any Outlook object—but it must be open for the procedure to work. The final line displays the Categories dialog, so you can set a category for the current item, OLItem. That’s all the procedure does, but you’ll continue by checking a category (color). If that category hasn’t been used before, the feature (not the code) will prompt you to set a keystroke shortcut. You can do so or cancel that prompt.
There is a bit of error-handling for those times when no item is open. The code will display a warning message box and then quit the procedure.
SEE: Windows 11: Tips on installation, security and more (free PDF) (TechRepublic)
To enter the procedure, press Alt + F11 to open the Visual Basic Editor. In the Project Explorer to the left, select ThisOutlookSession so you can run the procedure in any window. You can enter the code manually or import the downloadable .cls file. If you enter the code manually, don’t paste from this web page. Instead, copy the code into a text editor and then paste that code into the ThisOutlookSession module. Doing so will remove any phantom web characters that might otherwise cause errors.
How to use the procedure in Outlook
Before running the procedure, check the security setting by clicking the File tab and then choosing Options. At the bottom of the left pane, click Trust Center and then click Trust Center Settings in the dialog. In the left pane, click Macro Settings. You’ll have four options. Click one of the three options that allow you to execute macros, as shown in Figure A. Your level or protection depends on you and your organization; I chose Notification for All Macros. Click OK twice. If you have to change this option, close and restart Outlook before you continue.
Now, let’s execute the procedure as follows:
- Open an existing email.
- Click the Developer tab (if you don’t see the Developer tab, see “How to add the Developer tab” below).
- In the Macros group, click Macros.
- From the dropdown, click SetCategory (Figure B) and click Run.
- In the resulting dialog, choose a category color, such as blue. If blue hasn’t been chosen before, the feature (not the code) opens a second dialog that allows you to name the category and set a shortcut. Otherwise, click the Shortcut Key dropdown and choose the shortcut Ctrl + F2 (Figure C).
- The feature applies the blue category (Figure D).
You can close the email when you like; it’s categorized as blue. To remove the category, open the item, right-click the category color line and choose Clear Category.
Add the Developer tab
If you don’t see the Developer tab, you can quickly display it as follows:
- Click the Quick Access Toolbar dropdown and choose More Commands.
- Click Customize Ribbon in the left pane.
- In the list to the right, check Developer, as shown in Figure E.
- Click OK.
It’s unlikely that you’ll want to work through all those steps every time you want to run the procedure. Instead, add the macro to the Quick Access Toolbar. To do so, read How to add Office macros to the QAT toolbar for quick access.
Subscribe to the Developer Insider Newsletter
From the hottest programming languages to commentary on the Linux OS, get the developer and open source news and tips you need to know. Delivered Tuesdays and Thursdays