add a button to a new inspector

Add-in Express™ Support Service
That's what is more important than anything else

add a button to a new inspector
 
Guest


Guest


Here's the code I'm using to create a button on the standard toolbar in an
open email in outlook. The event is firing, b/c I get the "New Inspector"
msgbox to appear, but then I always get "error creating button". This code
for creating a button works in the main outlook window, but it does not when
an email is opened in a new window. Please help.

Private Sub myOlInspectors_NewInspector(ByVal Inspector As
Outlook.Inspector) Handles myOlInspectors.NewInspector
MsgBox("New Inspector")

' Create button on Standard Toolbar in Outlook when Outlook starts
Dim objStandardBar As CommandBar

Try
objStandardBar = Inspector.CommandBars.Item("Standard")
btnCombine =
CType(objStandardBar.Controls.Add(Type:=MsoControlType.msoControlButton,
Temporary:=True), CommandBarButton)
Posted 20 Oct, 2004 14:03:44 Top
Guest


Guest


I am puzzled this code doesn't work with you. I have tested it in VB.NET. All works fine.
Try to put the following code:

Private Sub AddinModule_OlNewInspector(ByVal sender As Object, ByVal inspector As Object, ByVal folderName As String) Handles MyBase.OlNewInspector
Dim objStandardBar As Microsoft.Office.Core.CommandBar

Try
objStandardBar = inspector.CommandBars.Item("Standard")
btnCombine = objStandardBar.FindControl(Type:=Microsoft.Office.Core.MsoControlType.msoControlButton, Tag:="12F6BC46-9D04-4c1a-A4E5-64BB756410B4", Recursive:=True)
If btnCombine Is Nothing Then
btnCombine = CType(objStandardBar.Controls.Add(Type:=Microsoft.Office.Core.MsoControlType.msoControlButton, Temporary:=True), Microsoft.Office.Core.CommandBarButton)
btnCombine.Caption = "My Button"
btnCombine.Tag = "12F6BC46-9D04-4c1a-A4E5-64BB756410B4"
End If
Catch e As Exception
System.Windows.Forms.MessageBox.Show(e.Message)
End Try

End Sub
Posted 21 Oct, 2004 04:00:07 Top