ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I create a custom image for a toolbar? (https://www.excelbanter.com/excel-programming/364981-how-do-i-create-custom-image-toolbar.html)

[email protected]

How do I create a custom image for a toolbar?
 
The toolbar is being generated upon loading of the excel add-in via the
following code:

Set cmdRW = CommandBars.Add(Name:="DT")


With cmdRW

With .Controls.Add(Type:=msoControlButton)
.TooltipText = "New Sheet"
.OnAction = "Sheet"
.FaceId = 98

I know how to design a new button image when creating a toolbar
manually, but how do I do so when creating the toolbar programtically?

Thanks!


[email protected]

How do I create a custom image for a toolbar?
 
I found the following code, however the image is not displaying in the
toolbar, just a blank space...any help would be greatly appreciated!

THanks


Sub AddPictureToButton()

Dim oShape As Shape

'Place the graphic in the document
Set oShape = ActiveDocument.Shapes.AddPicture(FileName:= _
"PathAndNameOfPicture.gif")

oShape.Select

'Copy graphic
Selection.CopyAsPicture

'Delete from document
Selection.Delete

'Copy the graphic to the first button on your toolbar
'Replace the name of the commandbar with your own
CommandBars("TemplateCommandbar").Controls(1).Past eFace

Set oShape = Nothing

End Sub

---------------------------------------------------------------------------------------------------------

wrote:
The toolbar is being generated upon loading of the excel add-in via the
following code:

Set cmdRW = CommandBars.Add(Name:="DT")


With cmdRW

With .Controls.Add(Type:=msoControlButton)
.TooltipText = "New Sheet"
.OnAction = "Sheet"
.FaceId = 98

I know how to design a new button image when creating a toolbar
manually, but how do I do so when creating the toolbar programtically?

Thanks!



JNW

How do I create a custom image for a toolbar?
 
Instead of
.FaceId = 98

Put...
.Picture = LoadPicture("C:\My picture location")

Note that only certain file types can be used (I don't remember off hand
which ones don't work).

JNW

" wrote:

The toolbar is being generated upon loading of the excel add-in via the
following code:

Set cmdRW = CommandBars.Add(Name:="DT")


With cmdRW

With .Controls.Add(Type:=msoControlButton)
.TooltipText = "New Sheet"
.OnAction = "Sheet"
.FaceId = 98

I know how to design a new button image when creating a toolbar
manually, but how do I do so when creating the toolbar programtically?

Thanks!




All times are GMT +1. The time now is 10:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com