Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Load bitmap on a button?

20 views
Skip to first unread message

rola

unread,
May 13, 2002, 4:09:32 AM5/13/02
to
Hi All,

is it possible to load bitmap from a file to serve as a button face. If so,
how? (I need to change the button face from code.)

Thank you

Rola


Rob Bovey

unread,
May 13, 2002, 5:00:31 AM5/13/02
to
Hi Rola,

The syntax for loading a picture at run-time looks something like this:

CommandButton1.Picture = LoadPicture("C:\Files\MyPicture.bmp")

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"rola" <rlab...@hotmail.com> wrote in message
news:ua2JRWl#BHA.1740@tkmsftngp02...

rola

unread,
May 13, 2002, 5:48:01 AM5/13/02
to
Hi Rob,

Thank you very much for your answer.

Regards
Rola

"Rob Bovey" <Rob_...@msn.com> wrote in message
news:evmfoyl#BHA.2520@tkmsftngp05...

rola

unread,
May 13, 2002, 10:00:29 AM5/13/02
to
Hi Rob,

Does it work even with Toolbar buttons (I need to change toolbar button's
face, not command button's one)? I've tried it and got the following
message: "Method or data member not found."

Rola

"Rob Bovey" <Rob_...@msn.com> wrote in message
news:evmfoyl#BHA.2520@tkmsftngp05...

Rob Bovey

unread,
May 13, 2002, 12:09:37 PM5/13/02
to
Hi Rola,

No, command bar buttons are completely different. There's no simple way
to load a picture into a command bar button directly from a file on disk.
The easiest way to handle this is to put a copy of the graphics file you
want to use as your button face on a worksheet in the workbook. Then, to
make this file a button face you'd do something like this:

Sheet1.Shapes("GraphicName").CopyPicture
CommandBars("MyBar").Controls("MyControl").PasteFace

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"rola" <rlab...@hotmail.com> wrote in message

news:e6y89ao#BHA.1892@tkmsftngp02...

Stephen Bullen

unread,
May 13, 2002, 3:50:34 PM5/13/02
to
Hi Rob,

> There's no simple way
> to load a picture into a command bar button directly from a file on disk.

Just a FWIW, but in Office XP, command bar buttons were given a .Picture
property, so you can use the same oBtn.Picture = LoadPicture() syntax (it
was one of the things I sent in to MSWish!)

Regards

Stephen Bullen
Microsoft MVP - Excel
www.BMSLtd.co.uk

Rob Bovey

unread,
May 13, 2002, 8:43:48 PM5/13/02
to
> Just a FWIW, but in Office XP, command bar buttons were given a .Picture
> property, so you can use the same oBtn.Picture = LoadPicture() syntax (it
> was one of the things I sent in to MSWish!)

Hi Stephen,

Cool! I hadn't noticed that one.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *

"Stephen Bullen" <Ste...@BMSLtd.co.uk> wrote in message
news:VA.0000007...@bmsltd.co.uk...

rola

unread,
May 15, 2002, 2:20:48 AM5/15/02
to
Hi Rob,

Thank you for your advice but I'm afraid I don't know how to do this since
I'm coding in Personal.xls file and want the graphics to appear on the
toolbar buttons before any workbook is open. I've tried putting the Image
control on the UserForm instead but didn't know how to copy the bitmap from
the Image control. Can you advise on this, please?

Rola

"Rob Bovey" <Rob_...@msn.com> wrote in message

news:OChYdip#BHA.1940@tkmsftngp04...

Rob Bovey

unread,
May 15, 2002, 4:11:45 AM5/15/02
to
Hi Rola,

Your Personal.xls workbook is just a normal workbook that's been saved
hidden. Choose Window/Unhide from the Excel menu to unhide it. You can then
save copied pictures on one of its worksheets (it has to have at least one,
all workbooks do). Once you've done that, use the Windows menu to rehide it
and you can save it hidden by using the Save button in the Visual Basic
Editor.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"rola" <rlab...@hotmail.com> wrote in message

news:OWiqWj9#BHA.2524@tkmsftngp05...

rola

unread,
May 15, 2002, 10:21:19 AM5/15/02
to
Hi Rob,

Despite your explanation I am still not able to do it so it works. I copied
bitmap on the sheet (it was given a name "Picture 1" automatically) and then
used the two lines you suggested. In this case it looks like this:

Sheets(1).Shapes("Picture 1").CopyPicture
CommandBars("BGSToolBar").Controls("cmdWordCount").PasteFace

When Excel starts an error is raised on the second line of the two and the
following error message appears: "Object variable or With block variable not
set". Object reference has been set for both object variables (BGSToolBar
and cmdWordCount"). What am I doing wrong?

Rola

"Rob Bovey" <Rob_...@msn.com> wrote in message

news:uNO1wg##BHA.1880@tkmsftngp04...

janan...@gmail.com

unread,
Sep 19, 2018, 7:00:59 AM9/19/18
to
0 new messages