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
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...
Thank you very much for your answer.
Regards
Rola
"Rob Bovey" <Rob_...@msn.com> wrote in message
news:evmfoyl#BHA.2520@tkmsftngp05...
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...
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...
> 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
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...
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...
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...
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...