PDA

View Full Version : [SOLVED] Applying icon to commad BAR not button (user defined add in)



fibonacci
12-17-2013, 12:40 PM
Hello Everyone,

Is there a way to apply icon to command BAR?

I found that part of code online:



Private Sub Workbook_Open()
' vbaexpress.com/kb/getarticle.php?kb_id=427#instr
' 3/22/2010
Dim cmbBar As CommandBar
Dim cmbControl As CommandBarControl
Set cmbBar = Application.CommandBars("Worksheet Menu Bar")
If cmbBar.Controls(cmbBar.Controls.count).Caption <> "" Then
Set cmbControl = cmbBar.Controls.Add(Type:=msoControlButton, Temporary:=True)
End If
Set cmbControl = cmbBar.Controls.Add(Type:=msoControlPopup, Temporary:=True) 'adds a menu item
With cmbControl
.Caption = "&VBA Setup" 'names the menu item
With .Controls.Add(Type:=msoControlButton) 'adds a dropdown button to the menu item
.Caption = "Add-Ins Install" 'adds a description to the menu item
.OnAction = "ToolsInitDLL.AddinsInstall" 'runs the specified macro
.FaceId = 220 'assigns an icon to the dropdown
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Add-Ins Un-Install"
.OnAction = "ToolsInitDLL.AddInsUninstall"
.FaceId = 220
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "Apply Macro Shortcuts"
.OnAction = "ToolsInitDLL.ApplyShortCuts"
.FaceId = 220
End With
With .Controls.Add(Type:=msoControlButton)
.Caption = "VB Library References"
.OnAction = "ToolsInitDLL.ListObjLibReferences"
.FaceId = 220
End With
End With
End Sub

I modified it to my needs, I applied FaceIds of my choosing to all buttons I've created.

But I'm wondering if there is a way to apply icon to command Bar. Here is where I want my icon to be:


i.imgur.com/TXrKq3D.png

I've tried .FaceId but it seems that it doesn't work for command Bars. Any ideas?

Jan Karel Pieterse
12-17-2013, 10:48 PM
A commandbar does not have an icon. The closest you can get is using the first button.

snb
12-18-2013, 01:57 AM
crossposted here: http://www.ozgrid.com/forum/showthread.php?t=184832

fibonacci
12-18-2013, 09:40 AM
>Jan Karel Pieterse, what a shame... :( but thank you for your help :)

>snb, is crossposted not allowed? I thought that vbaexpress and ozgrid are two separate portals/forums

royUK
12-18-2013, 11:24 AM
I suggest that you read this

http://www.excelguru.ca/content.php?184-A-message-to-forum-cross-posters

Then post links in each Forum to your posts in other Forums

fibonacci
12-18-2013, 12:53 PM
>royUK, apologies for everyone, thanks for very useful link, won't happen again, promise ;)