Outlook 2003 Sp1 Inspector Problem

  • Thread starter Thread starter John Britto
  • Start date Start date
J

John Britto

Hi,

I have a button in the new mail dialog, which I added from the NewInspector
event, which is working in outlook 2003 without sp1.

In 2003 with Sp1 , I'm able to create the button, but the onclick event is
not getting triggered for that button. Why?

Thx for ur help
John
 
Show some of your code. I haven't seen problems with my Inspector buttons in
Outlook 2003 SP1.
 
Thx for ur reply.

here is my code, this works for office 2003 without sp1.
From this code the button is created but I don't get the onclick event for
the button.

Public WithEvents objSearchButton As Office.CommandBarButton
Public WithEvents objInspectors As Outlook.Inspectors
Public WithEvents objInspector As Outlook.Inspector

Private Sub objInspectors_NewInspector(ByVal Inspector As Outlook.Inspector)
dim objMailItem
If Inspector.CurrentItem.Class = 43 Then
Set objInspector = Inspector
Set objMailItem = Inspector.CurrentItem
If (objMailItem.Size = 0) And (objMailItem.EntryID = "") Then
Call SetSearchButton(Inspector)
End If
End If
End Sub

Private Sub SetSearchButton(objInspector As Inspector)
Dim bFoundStandardBar As Boolean, bFound As Boolean
Dim objBar As Office.CommandBar
Dim i As Integer, intCount As Integer

bFoundStandardBar = False
bFound = False

Set objBar = Nothing
For i = 1 To objInspector.CommandBars.Count
If objInspector.CommandBars.Item(i).Name = "Standard" Then
Set objBar = objInspector.CommandBars.Item(i)
bFoundStandardBar = True
Exit For
End If
Next

If bFoundStandardBar And (Not objBar Is Nothing) Then
intCount = objBar.Controls.Count
For i = 1 To intCount
If objBar.Controls.Item(i).ToolTipText = "New Tool Tip" Then
Set objSearchButton = objBar.Controls.Item(i)
bFound = True
'Exit For
End If
Next

If Not bFound Then
Set objSearchButton =
objBar.Controls.Add(Type:=msoControlButton, Before:=4)

With objSearchButton
.Caption = g_StrSearchButtonText
.ToolTipText = g_StrSearchToolTipText
Clipboard.SetData frmImage.imgSoffrontLogo.Picture
.PasteFace
.Style = msoButtonIconAndCaption
End With
End If

End If
End Sub

Private Sub objSearchButton_Click(ByVal Ctrl As Office.CommandBarButton,
CancelDefault As Boolean)
msgbox "Test"
End Sub
 
This is running where? In a COM addin or in the VBA project?

In a COM addin you always use the ProgID you get in the On_Connection event
handler and set the button's click event handler this way:

..OnAction = "!<" & gstrProgID & ">"

To derive the ProgID in On_Connection you would do this:

gstrProgID = AddInInst.ProgId

You also should always set any buttons you create as temporary:

..Controls.Add(Type:=msoControlButton, Temporary:=True, Before:=4)
 
Back
Top