VSTO CommandBarButton的位置

时间:2009-05-12 09:26:34

标签: vb.net outlook vsto outlook-addin outlook-2003

我正在编写一个VSTO加载项,为Outlook 2003中的所有新MailItem添加标准工具栏按钮。

我已经完成了它,但我看不出如何在任务栏上设置按钮的位置 - 理想情况下我想把它放在发送按钮旁边。

这是我到目前为止的代码。

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

非常感谢任何帮助!

谢谢, 吉姆。

2 个答案:

答案 0 :(得分:1)

我应该使用commandBar.AddControl(control, position)语法

答案 1 :(得分:-1)

Outlook 2007中的

(Office.CommandBarButton)commandBars["Standard"].Controls.Add(Office.MsoControlType.msoControlButton, System.Reflection.Missing.Value, System.Reflection.Missing.Value,2,true);

其中2是职位数。