LoadPicture for a ControlButton help

M

micmacuk

Hello,

I am writing a custom toolbar and I wish to assigne a picture to one of
the control button but my syntax doesn't work. It bugs on .Picture=

Could someone help ?


Set cb = Application.CommandBars.Add(Name:="ToolBar1", temporary:=True)


With cb
Set cbpop = .Controls.Add(Type:=msoControlButton, temporary:=True)
With cbpop
..Picture = LoadPicture("C:\STOCK
CONTROL\Data-Macro\ArrRedLeftPlain.bmp")
..OnAction = ThisWorkbook.Name & "!Macro_Vide"
End With
End With

Cheers
Francois
 
T

Tom Ogilvy

What version of excel. I believe this is only supported in xl2003 (perhas
2002).
 
M

micmacuk

May be I could turn around this by creating a custom hiden toolbar with
my custom buttom and copy them in the toolbar I want to use...
But if so how could I copy those buttons in VBA ??
 
T

Tom Ogilvy

In xl2000 you would copy the picture to the clipboard and then use pasteface
- so you migt have to import it into the worksheet first.
 
M

micmacuk

Thanks Tom it works...
How can I give a "name" to the "shape" picture.

I have paste my icon pic. on my data sheet and I have used the macro
recorder to get the name of the pic. and was surprise to see the name
("Picture 4") although it is the only pic on this sheet.

Also is there a way to copy the pic frpm the disk and paste it onto my
data sheet (and then give it a name...) ?
 
T

Tom Ogilvy

turn on the macro recorder while you do

Insert=>Picture from File

I get
ActiveSheet.Pictures.Insert( _
"C:\Documents and Settings\OgilvyTW\My Documents\My
Pictures\Part1.jpg").Select

so to use that, some modifications:

Dim Pic as Picture
Dim sName as String
sName = "C:\Myfiles\MyPictures\House.jpg"
set pic = Activesheet.Pictures.Insert(sName)
Pic.Name = "doghouse"
 

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