Solved

Outlook Categories Toolbar

Posted on 2010-09-03
15
468 Views
Last Modified: 2012-05-10
How can i create a toolbar which has all the categories as buttons (or a dropdown box since there are about 20 categories)
0
Comment
Question by:awesomejohn19
  • 9
  • 5
15 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 33599289
Hi, awesomejohn19.

What version of Outlook?
0
 

Expert Comment

by:brimac21
ID: 33599383
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
 

Author Comment

by:awesomejohn19
ID: 33599384
Outlook 2003
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
LVL 76

Expert Comment

by:David Lee
ID: 33599419
This can be done with a simple bit of scripting.  Which do you prefer, buttons or a dropdown menu?
0
 

Author Comment

by:awesomejohn19
ID: 33599441
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
 
LVL 76

Expert Comment

by:David Lee
ID: 33599563
20 isn't too many if you prefer buttons.
0
 

Author Comment

by:awesomejohn19
ID: 33599569
ok than buttons would be great :)
0
 
LVL 76

Expert Comment

by:David Lee
ID: 33600507
One more question.  Do you plan to use this with messages you've received or with messages you're sending, or both?
0
 

Author Comment

by:awesomejohn19
ID: 33600544
received messages only
0
 
LVL 76

Assisted Solution

by:David Lee
David Lee earned 500 total points
ID: 33600603
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
 
LVL 76

Assisted Solution

by:David Lee
David Lee earned 500 total points
ID: 33600619
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
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 33600640
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
 
LVL 76

Expert Comment

by:David Lee
ID: 33600670
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
 

Author Closing Comment

by:awesomejohn19
ID: 33617250
Perfect, thanks a lot
0
 
LVL 76

Expert Comment

by:David Lee
ID: 33621687
You're welcome.  Glad I could help.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question