Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-02-23
3
Medium Priority
?
1,024 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 49

Accepted Solution

by:
Jackie Man earned 1500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Outline Suppose you have some simple text based data in Excel that you would like to display as a PowerPoint presentation. Of course it would be possible to write some fairly complex VBA code that created a new slide for each line of the Excel data…
With the internet and the ease of information transference, many professional jobs can be done anywhere today.  Why should it make a difference whether an x-ray is read in India or the United States as long as the radiologist is qualified?   Outso…
The viewer will learn how to edit text. This includes Font, Spacing, Resizing, Color, and other special text options.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

660 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