【发布时间】: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