Please help with newinspector event

L

lanem

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)

btnCombine.Caption = "Click me"
btnCombine.Style = MsoButtonStyle.msoButtonCaption
btnCombine.Visible = True
Catch ex As Exception
MsgBox("Error creating button.", MsgBoxStyle.Critical, "Error")
End Try
End Sub
 

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