Posted to microsoft.public.excel.programming
|
|
Custom Button Images
Good approach. You can even pick any button on the toolbar.
--
Gary''s Student - gsnu200727
"Pflugs" wrote:
I have found a way. After a few more hours of digging, I found this example
in the help menu:
Sub ChangeButtonImage()
Dim picPicture As IPictureDisp
Dim picMask As IPictureDisp
Set picPicture = stdole.StdFunctions.LoadPicture( _
"c:\images\picture.bmp")
Set picMask = stdole.StdFunctions.LoadPicture( _
"c:\images\mask.bmp")
'Reference the first button on the first command bar
'using a With...End With block.
With Application.CommandBars.FindControl(msoControlButt on)
'Change the button image.
.Picture = picPicture
'Use the second image to define the area of the
'button that should be transparent.
.Mask = picMask
End With
End Sub
Thus, to complete my company add-in, I will program code to create a custom
toolbar and menu, and then the code will load the pictures from a company
shared folder. I think that will work nicely.
Thanks for helping me!
Pflugs
"Gary''s Student" wrote:
I see. Since it is easy to change the toolbar button images manually, it can
be done with VBA. The Macro Recorder won't help. I'll investgate and update
this tomorrow.
--
Gary''s Student - gsnu200727
"Pflugs" wrote:
That's interesting and useful, but I really want to change the image of a
toolbar or menu button, not a forms or controls button. Do you know of any
way to do this using VBA?
Thanks,
Pflugs
"Gary''s Student" wrote:
If you create the button with the Controls toolbox rather than forms, then
right-click the button and select Properties. Go down to picture, select it
and pick a picture from the resulting dialog box
--
Gary''s Student - gsnu200727
"Pflugs" wrote:
I know how to create custom toolbars and menus, but I want to design my own
button images (say in Paint or Photoshop) and attach those to my custom
commands. I found this site:
http://www.vertex42.com/ExcelTips/ex...r-buttons.html
that shows how to download GIF files and paste the image to a button or menu
item. Is this possible programmatically? Or can I set a button image from a
file when I create the menu from my VBA code?
Thanks,
Pflugs
|