programmatically change icons on a menubar

A

akh2103

Hello--how does one programmatically change the icons on a menubar? The
object browser is sort of cryptic on this point. More specifically, I
am looking to remove all icons from the buttons on my add-in menubar.
Thanks, Abe
 
B

Bob Phillips

Are you referring to a menu that your addin creates? If so, it will be in
the code that creates the menu, and that would need adjusting.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
P

Peter T

Run ButtonStyles for a few ideas.

Sub newTestBar()
Dim i As Long

On Error Resume Next
CommandBars("TestBar").Delete
On Error GoTo 0

With CommandBars.Add("TestBar", msoBarFloating, False, True)

For i = 1 To 5
With .Controls.Add(msoControlButton)
.Caption = "Button " & i
.FaceId = i + 79
End With
.Visible = True
Next
End With
End Sub

Sub ButtonStyles()
Dim cBar As CommandBar
Dim cbb As CommandBarButton
Dim sty As Long, i As Long

On Error Resume Next
Set cBar = CommandBars("TestBar")
If cBar Is Nothing Then
newTestBar
Set cBar = CommandBars("TestBar")
End If
On Error GoTo 0

sty = msoButtonIcon ' 1
sty = msoButtonCaption ' 2
sty = msoButtonIconAndCaption ' 3

For i = 1 To 3
sty = i
For Each cbb In cBar.Controls
cbb.Style = sty
'to completely remove icon -
'cbb.FaceId = 1 or cbb.BuiltInFace = True
Next
Stop ' look at the bar
Next

' cBar.Delete ' uncomment to delete the bar
End Sub

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top