• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 494
  • Last Modified:

Outlook Categories Toolbar

How can i create a toolbar which has all the categories as buttons (or a dropdown box since there are about 20 categories)
0
awesomejohn19
Asked:
awesomejohn19
  • 9
  • 5
3 Solutions
 
David LeeCommented:
Hi, awesomejohn19.

What version of Outlook?
0
 
brimac21Commented:
As far as I know this cannot be done in outlook natively. However there is a third party app called Category Manager 3.0 that will put all of your categories in a side-bar. You can try it for free for 30 days. http://www.vboffice.net/product.html?pub=20&lang=en&cmd=detail&id=2006063
0
 
awesomejohn19Author Commented:
Outlook 2003
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
David LeeCommented:
This can be done with a simple bit of scripting.  Which do you prefer, buttons or a dropdown menu?
0
 
awesomejohn19Author Commented:
Buttons would be easier but the number of categories I would like to use is around 20 so I guess dropdown would be better.
0
 
David LeeCommented:
20 isn't too many if you prefer buttons.
0
 
awesomejohn19Author Commented:
ok than buttons would be great :)
0
 
David LeeCommented:
One more question.  Do you plan to use this with messages you've received or with messages you're sending, or both?
0
 
awesomejohn19Author Commented:
received messages only
0
 
David LeeCommented:
The code comes in three parts.  This is part #1.

Follow these instructions to add the code to Outlook.

   1. Start Outlook
   2. Click Tools > Macro > Visual Basic Editor
   3. If not already expanded, expand Microsoft Office Outlook Objects
   4. Right-click on Class Modules, select Insert > Class Module
   5. In the Properties panel click on Name and enter CatBtn
   6. Copy the code and paste it into the right-hand pane of Outlook’s VB Editor window
   7. Click the diskette icon on the toolbar to save the changes
   8. Close the VB Editor

Private WithEvents objButton As Office.CommandBarButton
Private strThisCat As String

Private Sub Class_Terminate()
    Set objButton = Nothing
End Sub

Private Sub objButton_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
    Dim olkItm As Object, arrCats As Variant, varCat As Variant, bolFound As Boolean, intCnt As Integer, strNewCat As String
    Select Case TypeName(Outlook.Application.ActiveWindow)
        Case "Explorer"
            Set olkItm = Outlook.Application.ActiveExplorer.Selection(1)
        Case "Inspector"
            Set olkItm = Outlook.Application.ActiveInspector.CurrentItem
    End Select
    arrCats = Split(olkItm.Categories, ", ")
    For Each varCat In arrCats
        If varCat = strThisCat Then
            bolFound = True
        Else
            strNewCat = strNewCat & ", " & varCat
        End If
    Next
    If Not bolFound Then
        strNewCat = strNewCat & ", " & strThisCat
    End If
    olkItm.Categories = strNewCat
    olkItm.Save
    Set olkItm = Nothing
End Sub

Public Sub Init(ByRef ofcParentBar As Office.CommandBar, ByVal strCatNum As String, strTipText As String)
    Set objButton = ofcParentBar.Controls.Add(msoControlButton)
    With objButton
        .Caption = strCatNum
        .Style = msoButtonCaption
        .TooltipText = strTipText
    End With
    strThisCat = strTipText
End Sub

Open in new window

0
 
David LeeCommented:
This is part #2.  

Follow these instructions to add the code to Outlook.

   1. Start Outlook
   2. Click Tools > Macro > Visual Basic Editor
   3. If not already expanded, expand Microsoft Office Outlook Objects
   4. Right-click on Class Modules, select Insert > Class Module
   5. In the Properties panel click on Name and enter CatBar
   6. Copy the code and paste it into the right-hand pane of Outlook’s VB Editor window
   7. Click the diskette icon on the toolbar to save the changes
   8. Close the VB Editor

Private ofcBar As Office.CommandBar
Private colBtns As Collection

Private Sub Class_Initialize()
    Set colBtns = New Collection
    CreateCATBar Outlook.Application.ActiveExplorer
End Sub

Private Sub Class_Terminate()
    Set colBtns = Nothing
    Set ofcBar = Nothing
End Sub

Private Sub CreateCATBar(olkWindow As Object)
    Dim objCatBtn As CatBtn, _
        intCnt As Integer, _
        objShell As Object, _
        arrTemp As Variant, _
        varChar As Variant, _
        strTemp As String, _
        arrCats As Variant, _
        varCat As Variant
    On Error Resume Next
    Set ofcBar = Outlook.Application.ActiveExplorer.CommandBars("CAT")
    On Error GoTo 0
    If TypeName(ofcBar) = "Nothing" Then
        'Create the toolbar
        Set ofcBar = olkWindow.CommandBars.Add("CAT", msoBarTop, False, True)

        'Create the buttons
        Set ofcButton = ofcBar.Controls.Add(msoControlButton)
        With ofcButton
            .Caption = "CAT"
            .Enabled = False
            .Style = msoButtonCaption
        End With

        'Create the category buttons
        intCnt = 1
        Set objShell = CreateObject("Wscript.Shell")
        arrTemp = objShell.RegRead("HKCU\Software\Microsoft\Office\11.0\Outlook\Categories\MasterList")
        For Each varChar In arrTemp
            If varChar <> "0" Then
                strTemp = strTemp & Chr(varChar)
            End If
        Next
        arrCats = Split(strTemp, ";")
        For Each varCat In arrCats
            Set objCatBtn = New CatBtn
            objCatBtn.Init ofcBar, intCnt, CStr(varCat)
            colBtns.Add objCatBtn
            intCnt = intCnt + 1
        Next
        
        'Make the bar visible onscreen'
        ofcBar.Visible = True
    End If
    Set objCatBtn = Nothing
    Set objShell = Nothing
End Sub

Open in new window

0
 
David LeeCommented:
This is part #3.

Follow these instructions to add the code to Outlook.

   1. Start Outlook
   2. Click Tools > Macro > Visual Basic Editor
   3. If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
   4. Copy the code and paste it into the right-hand pane of Outlook’s VB Editor window
   5. Click the diskette icon on the toolbar to save the changes
   6. Close the VB Editor
   7. Click Tools > Macro > Security
   8. Set the Security Level to Medium
   9. Close Outlook
  10. Start Outlook. Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run. Say yes.

Dim objCatBar As CatBar

Private Sub Application_Quit()
    Set objCatBar = Nothing
End Sub

Private Sub Application_Startup()
    Set objCatBar = New CatBar
End Sub

Open in new window

0
 
David LeeCommented:
If all worked correctly, then you should see a new toolbar with numbered buttons.  Mouse over a button and you'll see a tooltip displaying the category name.  Click a button and that category will be added to the currently selected item.  
0
 
awesomejohn19Author Commented:
Perfect, thanks a lot
0
 
David LeeCommented:
You're welcome.  Glad I could help.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 9
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now