Custom toolbar images

shrive22

Board Regular
Joined
Jun 10, 2002
Messages
120
I am creating a custom toolbar with vb code but am unsure of the correct way to add the button image in the code. This is what I have so far:

With Application.CommandBars.Add
.Name = ToolBarName
.Left = 200
.Top = 200
.Protection = msoBarNoProtection
.Visible = True
.Position = msoBarFloating
For iCtr = LBound(MacNames) To UBound(MacNames)
With .Controls.Add(Type:=msoControlButton)
.OnAction = "'" & ThisWorkbook.Name & "'!" & MacNames(iCtr)
.Caption = CapNamess(iCtr)
.Style = msoButtonIconAndCaption
.FaceId = 71 + iCtr
.TooltipText = TipText(iCtr)
End With
Next iCtr
End With


Does anyone know how I can add the image for the button icon in the code?

Also this code has the toolbar floating: left200 and top200 is there anyway to get the toolbar to dock on the top of excel with the other toolbars?

thanks
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
.Position = msoBarFloating

to

.Position = msoBarMenuBar

and remove the .Left and .Top properties.

will dock it up top.

When you say add the image, do you mean one from the existing face Id library? you have the right syntax for assigning the FaceId property..

If iCtr is not an integer...your faceId property won;t work.

http://www.j-walk.com/ss/excel/tips/tip40.htm

click that link for code to show you the face ids and get their numbers...
 
Upvote 0
http://www.oaltd.co.uk/mvp/MVPPage.asp

on that link there is an addin that lets you see the available button faces and their associated ID. Creating your own is pretty involved in developing a bitmap image that can then be converted to an icon or button image for use in excel...

the addin name is BtnFaces.zip about 2/3 down the page. There are number of really usefull add-ins there....
 
Upvote 0
re custom image

If I already have the bitmaps, do you know how to write the code to attach them to the buttons or do you know of any place that has a tutorial??

thanks
 
Upvote 0

Forum statistics

Threads
1,215,349
Messages
6,124,427
Members
449,158
Latest member
burk0007

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top