PC Review


Reply
Thread Tools Rate Thread

Custom Button Images

 
 
=?Utf-8?B?UGZsdWdz?=
Guest
Posts: n/a
 
      8th Jun 2007
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      8th Jun 2007
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

 
Reply With Quote
 
=?Utf-8?B?UGZsdWdz?=
Guest
Posts: n/a
 
      8th Jun 2007
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

 
Reply With Quote
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      8th Jun 2007
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

 
Reply With Quote
 
=?Utf-8?B?UGZsdWdz?=
Guest
Posts: n/a
 
      8th Jun 2007
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(msoControlButton)
'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

 
Reply With Quote
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      8th Jun 2007
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(msoControlButton)
> '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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom images on a button or other control ti@sonic.net Powell Microsoft Excel Programming 3 30th Jul 2009 06:06 PM
Manipulating button images in a custom toolbar =?Utf-8?B?QmFycnk=?= Microsoft Word Document Management 5 23rd Jul 2007 10:40 PM
adding custom images to a button on custom toolbar Mousam Microsoft Excel Programming 1 13th Jul 2007 04:28 PM
Custom Button Images and Add-ins =?Utf-8?B?UGxhbiBDaGVja2Vy?= Microsoft Word Document Management 5 6th Apr 2007 07:05 PM
Export custom Macro Button Images RWN Microsoft Excel Misc 1 26th Nov 2006 10:53 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:49 AM.