How to set CommandBarButton Picture

R

Ryan

I've been trying to set the picture on a commandbarbutton but I keep
getting an
automation error, catastrophic failure
error. I've tried this way:

Dim graphic As IPictureDisp
graphic = LoadPicture("c:\on.bmp")
oCBB_Switch.Picture = graphic

The picture loads correctly but when I assign the picture i get the
error. Can someone please help me out this it driving crazy.

Thanks
 
M

Michael Höhne

I'm not sure, but maybe

Set oCBB_Switch.Picture = graphi

could help (notice the Set keyword at the beginning). If you don't use it, the default property will be used, which is Handle, meaning your code is actually

oCBB_Switch.Picture.Handle = graphic.Handl

If this solves your problem, you should also consider to set the button mask bitmap to create a transparent background for your image. And don't forget to set the buttons Style property to MsoButtonStyle.msoButtonIconAndCaptio

Michae
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top