1
從Outlook檢查刪除命令欄這是從這個代碼我正在成功地在Microsoft Outlook檢查添加按鈕,但是當新郵件在Outlook檢查打開(在收件箱中雙擊)按鈕sccesfully加入我的代碼,但如果我點擊同一主再次然後將兩個按鈕在Outlook中添加督察所以調用事件之前,我想刪除或刪除以前的按鈕用vb.net
如何從督察刪除按鈕?
Private Sub inspectors_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector) Handles inspectors.NewInspector
Try
Private MenuBar As Office.CommandBar
Private ButtonOne As Office.CommandBarButton
Dim mailItem As outlook.MailItem = TryCast(Inspector.CurrentItem, outlook.MailItem)
If Not (mailItem Is Nothing) Then
Try
MenuBar = Inspector.CommandBars.Add("Mail", Office.MsoBarPosition.msoBarTop, False, True)
MenuBar.Visible = True
MenuBar.Protection = Microsoft.Office.Core.MsoBarProtection.msoBarNoCustomize
ButtonOne = MenuBar.Controls.Add(Office.MsoControlType.msoControlButton, , , , True)
'ButtonOne.Caption = "Archive"
'ButtonOne.Tag = "My Button"
Dim newIcon As Icon = My.Resources.iiMS_32x32
Dim newImageList As New ImageList
newImageList.Images.Add(newIcon)
Clipboard.SetDataObject(newImageList.Images(0), False)
With ButtonOne
.Style = Office.MsoButtonStyle.msoButtonIconAndCaption
.Caption = ButtonCaption
.FaceId = 65
.Tag = menuTag
ButtonOne.PasteFace()
End With
Try
AddHandler ButtonOne.Click, AddressOf ButtonClick
Catch ex As Exception
writelog("Error Occured in preview windows while adding a Handler, Error: " & ex.Message)
MessageBox.Show("Application Error, Please Check Error Log", strCaption, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Catch ex As Exception
writelog(ex.Message)
writelog(ex.StackTrace)
End Try
End If
Catch ex As Exception
writelog(ex.Message)
writelog(ex.StackTrace)
End Try
End Sub