【问题标题】:VSTO CommandBarButton positionVSTO CommandBarButton 位置
【发布时间】:2009-05-12 09:26:33
【问题描述】:

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

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

这是我目前的代码。

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

任何帮助将不胜感激!

谢谢, 吉姆。

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      在 Outlook 2007 中:

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

      其中2 是位置数。

      【讨论】:

      • 欢迎来到 SO。请编辑您的帖子以正确格式化代码(帖子编辑器中有集成帮助)。
      猜你喜欢
      • 2021-08-27
      • 1970-01-01
      • 2019-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-31
      • 1970-01-01
      • 2013-01-12
      相关资源
      最近更新 更多