Click event from CommandButton in inspector window not fired

H

Hans Kaashoek

Hi all,

I created a com addin in outlook 2002 using office 2002 developer
When a new inspector , like a new mailitem, is opened the button
appears in a new toolbar, but when I click on this button nothing
happens (see code below).
What am I doing wrong?

thnx in advance
'Code starts Here

Implements IDTExtensibility2
Dim myOlapp As New Outlook.Application
Private WithEvents cmdBtn2 As Office.CommandBarButton
Public WithEvents myOlInspectors As Outlook.Inspectors
Public Sub Initialize_handler()

Set myOlInspectors = myOlapp.Inspectors
End Sub
Private Sub myOlInspectors_NewInspector(ByVal Inspector As
Outlook.Inspector)
On Error GoTo errh:

MsgBox "newinspector"
Dim cmdToolbar1 As CommandBar
Dim cmdBtn2 As CommandBarButton

Set cmdToolbar1 = Inspector.CommandBars.Add("Members DL1",
msoBarTop, , True)

cmdToolbar1.Visible = True

Set cmdBtn2 = cmdToolbar1.Controls.Add(Type:=msoControlButton)
cmdBtn2.Style = msoButtonCaption
cmdBtn2.Visible = True

cmdBtn2.Caption = "Select recipients from
distributionlist"
cmdBtn2.Tag = "cmdBtn2"
cmdBtn2.OnAction = ""
MsgBox "button"
Set cmdToolbar1 = Nothing '

Exit Sub

errh:

MsgBox er & " " & Err.Description & " " & Err.Number
Resume Next
End Sub





Private Sub cmdBtn2_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean)

msgbox "jippie"
Load MembersDistributionList
MembersDistributionList.Show


End Sub

Private Sub IDTExtensibility2_OnAddInsUpdate(custom() As Variant)

End Sub

Private Sub IDTExtensibility2_OnBeginShutdown(custom() As Variant)

End SubInitialize_handler


Private Sub IDTExtensibility2_OnConnection(ByVal Application As
Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode,
ByVal AddInInst As Object, custom() As Variant)


Set myOlapp = Application

End Sub

Private Sub IDTExtensibility2_OnDisconnection(ByVal RemoveMode As
AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)

Set myOlapp = Nothing
Set cmdBtn2 = Nothing
End Sub

Private Sub IDTExtensibility2_OnStartupComplete(custom() As Variant)


End Sub
'End code
 
K

Ken Slovak - [MVP - Outlook]

..OnAction = "!<" & gstrProgID & ">" where gstrProgID is the ProgID
passed in the On_Connection event handler in the AddInInst.ProgId
property.

See the VB6 COM addin sample ItemsCB on the Resources page at
www.microeye.com for a best practices looks at how to handle Outlook
COM addins. For one thing you should only be instantiating your addin
if there's at least one Explorer in Explorers when On_Connection fires
and look at the workarounds for On_Disconnection not firing if you
have any Outlook objects instantiated and the user closes Outlook.
Failure to handle that correctly will leave Outlook running in the
background in the Task Manager.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top