为什么我的VSTO Outlook加载项触发两次?
|
我有一个在启动时加载的VSTO Outlook 2007加载项。加载时会执行以下操作:
Private Sub ThisAddIn_Startup() Handles Me.Startup
explorer = Me.Application.ActiveExplorer()
AddHandler Application.ItemContextMenuDisplay, AddressOf Application_ItemContextMenuDisplay
AddHandler Application.Startup, AddressOf Application_CommandBarMenuDisplay
End Sub
然后,在此之后,AddHandlers将执行以下操作:
Sub Application_CommandBarMenuDisplay()
Dim cBar As Office.CommandBar = explorer.CommandBars(\"Standard\")
btnCommandBarMenu = CType(cBar.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, True), Office.CommandBarButton)
With btnCommandBarMenu
.BeginGroup = True
.Style = MsoButtonStyle.msoButtonIconAndCaption
.Caption = \"File TNRP Email\"
.Tag = \"File TNRP Email\"
.Picture = IPictureDisp.FromImage(My.Resources.label16)
.Mask = IPictureDisp.MaskFromImage(My.Resources.label16)
End With
AddHandler btnCommandBarMenu.Click, AddressOf btn_CommandBarMenuClick
End Sub
Sub Application_ItemContextMenuDisplay(ByVal CommandBar As Microsoft.Office.Core.CommandBar, ByVal Selection As Microsoft.Office.Interop.Outlook.Selection)
btnContextMenu = CommandBar.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, True)
With btnContextMenu
.BeginGroup = True
.Visible = True
.Style = MsoButtonStyle.msoButtonIconAndCaption
.Caption = \"File TNRP Email\"
.Tag = \"File TNRP Email\"
.Picture = IPictureDisp.FromImage(My.Resources.label16)
.Mask = IPictureDisp.MaskFromImage(My.Resources.label16)
End With
AddHandler btnContextMenu.Click, AddressOf btn_ContextMenuClick
End Sub
发送电子邮件后,该应用程序可以正常运行。但是,当我单击“按钮”时,则add in触发2倍,而当我使用上下文菜单时,其也会触发2倍。
知道为什么会这样吗?
没有找到相关结果
已邀请:
2 个回复
缮淳彼誊
骨乏唯瓜