Thank you for the reply... I am using Office 2003. The
following are some code snippets:
' declared within class module
Private WithEvents OutlookInspectors As Outlook.Inspectors
Private WithEvents CBButton As CommandBarButton
Code I use in the NewInspector event:
On Error Resume Next
'+
' Get reference to toolbar if it exists ignoring errors.
'-
CB = Inspector.CommandBars("MyAddInBar")
If (CB Is Nothing) And (Not Inspector.CurrentItem.Sent)
Then
CB = Inspector.CommandBars.Add("MyAddInBar",
MsoBarPosition.msoBarTop, False, True)
CB.Visible = True
CBC = CB.Controls.Add
(MsoControlType.msoControlButton, , , , True)
CBC.Style = MsoButtonStyle.msoButtonIcon
CBC.OnAction = "<!" & ProgID & ">" 'MyAddin.Connect
CBC.Tag = "MyAddin"
CBC.FaceId = 2114
CBC.TooltipText = "My tool tip text"
CBButton = CBC
CBC = Nothing
End If
CB = Nothing
'Below is my click event procedure
Private Sub CBButton_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef
CancelDefault As Boolean) Handles CBButton.Click
Msgbox("button clicked")
End Sub
This code successfully installs the commandbar and button
in a new Inspector regardless of the email editor. The
only problem is that the click event is not fired when
Word is the email editor. What I get is the
message "Macro could not be found..." I know it is
looking for a macro in the containing application
(Wordmail), but shouldn't CBButton_Click be fired in the
Outlook addin?
Again, the click event is fired when using Outlook
default email editor.