![]() |
Dynamic Toolbar icon
I cannot find a way to paste an image into a now toolbar icon using VB
macros. I create a toolbar button when I open a particular spreadsheet, and I destroy it when I close the worksheet. In this way, my toolbar is customized to the spreadsheet. But again I could not find a way to paste a new icon onto the button using macros. Any help is appreciated. Please reply to the group. |
Dynamic Toolbar icon
Sub ChangeIcon()
Dim cb1 As CommandBarButton Dim cBar As CommandBar Set cBar = Application.CommandBars("Your Toolbar") Set cb1 = cBar.Controls(Index of your control) cb1.Picture = UserForm2.Image1.Picture 'or whatever picture you want to assign End Sub HTH Die_Another_Day |
Dynamic Toolbar icon
In all versions, if the icon is in the clipboard, then use pasteface. If it
isn't in the clipboard, then copy it first. In xl2003 you can use the Picture property of the commandbarbutton. From the help on that property: 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 -- Regards, Tom Ogilvy "Gregory Kip" wrote: I cannot find a way to paste an image into a now toolbar icon using VB macros. I create a toolbar button when I open a particular spreadsheet, and I destroy it when I close the worksheet. In this way, my toolbar is customized to the spreadsheet. But again I could not find a way to paste a new icon onto the button using macros. Any help is appreciated. Please reply to the group. |
Dynamic Toolbar icon
Thank you both -- it works great, even in MS Project!
"Gregory Kip" wrote in message ... I cannot find a way to paste an image into a now toolbar icon using VB macros. I create a toolbar button when I open a particular spreadsheet, and I destroy it when I close the worksheet. In this way, my toolbar is customized to the spreadsheet. But again I could not find a way to paste a new icon onto the button using macros. Any help is appreciated. Please reply to the group. |
All times are GMT +1. The time now is 03:34 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com