Link to home
Start Free TrialLog in
Avatar of demteam
demteam

asked on

VSTO CommandBarButton position



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
            encryptButton.Delete()
        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

ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of demteam
demteam

ASKER

Worked beautifully. Thanks!