Change toolbar icon in VBA

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

I want to set a collection of icons into a toolbar, but I want to use
specific icon images.

How do I set them in VBA ?
Is there a list of the icon ID's with their images I can select from ?
(again set in VBA)
Can I use external icon files ?
 
Hi,

If you want to use built in ones, you need to look at "FaceId" in help.
There are absolutely thousands of them... This will show them all, but it's
not fast.

Sub faces()

Dim i As Integer
Dim cont As CommandBarControl
Dim bar As CommandBar

On Error GoTo catcher

Application.ScreenUpdating = False
Set bar = CommandBars.Add(Position:=msoBarFloating, MenuBar:=False,
temporary:=True)
Set cont = bar.Controls.Add(Type:=msoControlButton, temporary:=True)

Do
cont.FaceId = i
cont.CopyFace
ActiveSheet.Paste Cells(i + 1, 1)
i = i + 1
Loop

catcher:
If Err.Number = 1004 Then Resume Next
bar.Delete

End Sub

you can set them in your code by declaring a commandbarcontrol and then
setting its faceid property.

Sam
 
Back
Top