Directly Enter a Category Name

Before Outlook 2007, you could directly add a category to an item without saving it to the master category list. For Outlook 2007 and up this macro gives you that feature back.

Last modified: 2009/12/15 | Accessed: 45.680  | #80
◀ Previous sample Next sample ▶
ReplyAll ReplyAll
ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the e-mail.

Before Outlook 2007 you could directly enter a category for any item without saving it to the master category list. Since Outlook 2007 that's not possible anymore.

With the following code you'll get this functionality back. Multiple keywords can be entered separated by a comma or semi-colon.

Copy the code to the module "ThisOutlookSession", and save the project. Then you can create a commandbar button for calling the function by a right click on any toolbar, then choose Customize, Commands, Macros, and drag the name of the function onto a toolbar. By another right-click on the newly created button you can customize its style. (Perform these steps once for the folder view, and if you want to, once for any form for which the function should be available.)

Alternatively, you could also call the function by pressing alt+f8.

tip  How to add macros to Outlook
Public Sub EnterKeyword()
  Dim Coll As VBA.Collection
  Dim obj As Object
  Dim s$

  Set Coll = GetCurrentItems
  If Coll.Count = 0 Then Exit Sub

  s = InputBox("Keyword:")
  s = Trim$(s)
  If Len(s) = 0 Then Exit Sub

  For Each obj In Coll
    obj.Categories = obj.Categories & "," & s
End Sub

Private Function GetCurrentItems() As VBA.Collection
  Dim Coll As VBA.Collection
  Dim Win As Object
  Dim Sel As Outlook.Selection
  Dim obj As Object
  Dim i&

  Set Coll = New VBA.Collection
  Set Win = Application.ActiveWindow

  If TypeOf Win Is Outlook.Inspector Then
    Coll.Add Win.CurrentItem
    Set Sel = Win.Selection
    If Not Sel Is Nothing Then
      For i = 1 To Sel.Count
        Coll.Add Sel(i)
    End If
  End If
  Set GetCurrentItems = Coll
End Function
Category-Manager Category-Manager
With Category-Manager you can group your Outlook categories, share them with other users, filter a folder by category, automatically categorize new emails, and more. You can use the Addin even for IMAP.
email  Send a message