Link to home
Start Free TrialLog in
Avatar of ShootFirst
ShootFirstFlag for United States of America

asked on

Assign an icon to a vb.net add-in CommandBarButton

Hey guys,
I created an outlook add-in.  I would like to assign an image to command bar buttons.  I looked everywhere and have not been able to get anything to work.  Most solutions I found on EE used the “LoadPicture” method, but vb.net does not recognize it.  I believe this is a vb6 method...

Can someone help me out a little....?
Thank you!

Here is my code:
Imports System.Drawing

Public Class ThisAddIn

  Private Sub ThisAddIn_Startup() Handles Me.Startup

  End Sub

  Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown

  End Sub

  Private Sub Application_Startup() Handles Application.Startup
    Dim objCommandBar As Office.CommandBar = Nothing
    Dim objPrintBtn As Office.CommandBarButton
    Dim objSettingsBtn As Office.CommandBarButton
    Dim objPicture As stdole.IPictureDisp

    'Create the Print Attachments CommandBar.
    If objCommandBar Is Nothing Then
      objCommandBar = Application.ActiveExplorer().CommandBars.Add("Print", Office.MsoBarPosition.msoBarTop, False, True)
      objCommandBar.Visible = True
    End If

    objPicture = ?????

    'Create the Print Attachments CommandBar button.
    objPrintBtn = objCommandBar.Controls.Add(Office.MsoControlType.msoControlButton, 1, "", Reflection.Missing.Value, True)
    objPrintBtn.Visible = True
    objPrintBtn.Picture = objPicture
    'objPrintBtn.Caption = "Print Attachments"

    'Create the Print Settings CommandBar button.
    objSettingsBtn = objCommandBar.Controls.Add(Office.MsoControlType.msoControlButton, 1, "", Reflection.Missing.Value, True)
    objSettingsBtn.Visible = True
    objSettingsBtn.Caption = "Settings"

    'Create the Print Attachments and Settings handler/event.
    AddHandler objPrintBtn.Click, AddressOf PrintBtn_Click
    AddHandler objSettingsBtn.Click, AddressOf SettingBtn_Click

  End Sub

  Private Sub PrintBtn_Click()

    MsgBox("PrintBtn_Click")

  End Sub

  Private Sub SettingBtn_Click()

    MsgBox("SettingBtn_Click")

  End Sub

End Class

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Jackie Man
Jackie Man
Flag of Hong Kong image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ShootFirst

ASKER

Thanks for the help!
I was able to get it to wok using the link you provided.
No