Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Outlook Categories Toolbar

Posted on 2010-09-03
15
Medium Priority
?
490 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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 2000 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
Mailbox Overload?
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

636 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