【问题标题】:Add Custom button to Home tab将自定义按钮添加到主页选项卡
【发布时间】:2014-12-10 01:38:46
【问题描述】:

我正在尝试在 Outlook 2010 的默认主页选项卡中创建一个按钮。在 VS2010 中,我添加了一个 commandBarButton,但它不断添加到 AddIns 选项卡。我想在主页选项卡中显示。

这是我的代码:

Public Class ThisAddIn
Dim newToolBar As Office.CommandBar
Dim firstButton As Office.CommandBarButton
Dim selectExplorers As Outlook.Explorers

Private Sub ThisAddIn_Startup(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles Me.Startup
    selectExplorers = Me.Application.Explorers()
    AddHandler selectExplorers.NewExplorer, AddressOf _
        Me.NewExplorer_Event
    AddToolbar()
End Sub

Private Sub NewExplorer_Event(ByVal new_Explorer _
    As Outlook.Explorer)
    new_Explorer.Activate()
    newToolBar = Nothing
    Call Me.AddToolbar()
End Sub

Private Sub AddToolbar()

   Try
        button_1 = CType(newToolBar.Controls.Add(1),  _
            Office.CommandBarButton)
        'button_1.Size = New Size(100, 50)
        'button_1.Size.Height = 42
        With button_1
            '.Style = Office.MsoButtonStyle.msoButtonCaption
            .Style = Office.MsoButtonStyle _
            .msoButtonIconAndCaption
            .Caption = "Forward Email to Loop"
            .Height = 80
        End With

        If Me.firstButton Is Nothing Then
            Me.firstButton = button_1
            AddHandler firstButton.Click, AddressOf ButtonClick
        End If

        newToolBar.Visible = True
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try

End Sub

【问题讨论】:

    标签: vba vb.net outlook outlook-addin outlook-2010


    【解决方案1】:

    从 Outlook 2010 开始,使用旧 Explorer.Toolbars 集合添加的按钮将添加到“插件”选项卡(专为尚未针对 Outlook 2010 更新的旧插件而设计)。

    按钮只能从 COM 插件添加到功能区。请参阅http://msdn.microsoft.com/en-us/library/bb398246.aspx 了解更多信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-06
      • 1970-01-01
      • 2011-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多