Solved

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

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

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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
A high-level exploration of how our ever-increasing access to information has changed the way we do our jobs.
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now