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