Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro to Change Name and Icon of Menu Button 1

Status
Not open for further replies.

cyork

MIS
Apr 4, 2001
34
0
0
CA
Hi,

I would like to create an Excel file that, when opened, a few custom buttons are created, renamed and new icons selected.

I have been able to create the buttons with the macro but I don't know how the make the macro change & show the button name and change the button's picture to something other than the smiley face...

Thanks,

Chris
 
You need to set the style, caption and faceid properties of your commandbarbutton object. As a simple example, the following code adds a silly button to the Formatting toolbar:


set bb=application.commandbars(4).controls.Add(msocontrolbutton)
bb.style=msoButtonIconAndCaption
bb.caption="Hi!"
bb.faceid=10

The FaceID property can be set to any of the many built-in button icons. If none suit you, then you can make your own, with some more effort.
Rob
[flowerface]
 
That's perfect - thanks Rob. I'm assuming the icon represented for a given FaceID differs from PC to PC (based on what is installed), is this the case?
 
No, the FaceIDs are constants within Office. I think John Walkenbach's website has a program to show and select them.
Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top