VSTO CommandBarButton position

Posted on 2009-05-12
Last Modified: 2013-11-26

I'm writing a VSTO add-in to add a button the Standard toolbar for all new MailItems in Outlook 2003.

I've got it mostly finished, but I can't see to work out how to set the button's position on the taskbar - ideally I'd like to place it right next to the Send button.

Any help would be tremendously appreciated!

Thanks, Jim.

Private Sub colInsp_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector) Handles colInsp.NewInspector

    Dim msg As Outlook.MailItem

    Dim commandBar As Office.CommandBar

    Dim encryptButton As Office.CommandBarButton

    Dim olkitem As Object

    olkitem = Me.ActiveInspector().CurrentItem

    If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then

        msg = CType(Inspector.CurrentItem, Outlook.MailItem)

        commandBar = Inspector.CommandBars("Standard")

        encryptButton = commandBar.FindControl(Tag:="EncryptMail")

        If Not (encryptButton Is Nothing) Then


        End If

        encryptButton = CType(commandBar.Controls.Add(1), Office.CommandBarButton)

        encryptButton.Style = Office.MsoButtonStyle.msoButtonIconAndCaption

        encryptButton.FaceId = 718

        encryptButton.Caption = "Secure Email"

        encryptButton.Tag = "EncryptMail"

        If olkitem.Sensitivity = Outlook.OlSensitivity.olConfidential Then

            encryptButton.State = Office.MsoButtonState.msoButtonDown

        End If

        AddHandler encryptButton.Click, AddressOf encryptButton_Click

        msg = Nothing

    End If

End Sub

Open in new window

Question by:demteam
LVL 83

Accepted Solution

CodeCruiser earned 50 total points
ID: 24372160
Use the commandBar.AddControl(control, position) syntax instead

Author Closing Comment

ID: 31580460
Worked beautifully. Thanks!

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now