Solved

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

Posted on 2011-02-23
3
1,011 Views
Last Modified: 2012-05-11
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

0
Comment
Question by:ShootFirst
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
Jackie Man earned 500 total points
ID: 34968786
Maybe the info in the link below will help.

http://msdn.microsoft.com/en-us/library/ms268747(v=vs.80).aspx
0
 

Author Comment

by:ShootFirst
ID: 34970832
Thanks for the help!
I was able to get it to wok using the link you provided.
0
 

Author Closing Comment

by:ShootFirst
ID: 34970861
No
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question