Solved

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

Posted on 2011-02-23
3
1,013 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 44

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to rename move a batch of pdf files based on contents of the files 2 58
Exchange 2010 4 37
Transfer Office 2016 Volumen License (MAK) 1 140
OneNote in Read Only 9 336
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 advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.

821 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