Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default 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.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Drawing toolbar Icon Irv Excel Worksheet Functions 3 April 21st 07 01:18 AM
toolbar icon description Michael Abraham New Users to Excel 1 February 19th 06 03:18 PM
Icon in toolbar Nick Excel Programming 1 February 16th 04 11:57 AM
Add Icon to Toolbar SS[_3_] Excel Programming 1 January 16th 04 09:07 PM
icon in menu toolbar roland Excel Programming 1 November 20th 03 01:29 PM


All times are GMT +1. The time now is 08:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"