ShootFirst
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:
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No
ASKER
I was able to get it to wok using the link you provided.