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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SlingPlayer alternatives 1 30
Not showing JavaScript in the list 5 36
C# Single Form 8 27
Entity Framework 7 30
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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.…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

912 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

19 Experts available now in Live!

Get 1:1 Help Now