View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Embed Image in Add-In

Various ways, store or images on other images controls, hidden on main form,
or on a dummy form like an ImageList, or worksheet controls on a sheet in
your addin

- Hidden images on your main form
Set Me.CommandButton11.Picture = Me.Controls("hidden_image1").Picture

- Dummy form used like an ImageList
Dim frm As UserForm
Set frm = UserForm2
Load frm
Set Label2.Picture = frm.Controls("Image1").Picture
' Set Label2.Picture = frm.Controls(1).Picture
' Set Label2.Picture = frm.Image1Picture
Unload frm

- Worksheet controls on a sheet in your addin
could set a ref to all oleObjects on the sheet

Dim mOles as Oleobjects ' at module level

in the Initialize event
Set mOles = thisworkbook.Worksheets(1).OleObjects

'where needed
Set Me.Label1.Picture = mOles("ole_name").Object.Picture

To remove a picture from your control
Set Me.Label.Picture = Nothing


Which of the above methods might depend on the number and total file sizes
of images, each have pros & cons, eg

Hidden controls on main form is simplest but could impact form load time

Dummy ImageList form is nice 'cos you can lay out all your images on the
dummy and tab between forms to look what you've got while developing.

Worksheet image controls - best for large number / file size but also fine
for small qty

Regards,
Peter T



"Lazzaroni" wrote in message
...
Can anyone give me some pointers on how to embed images in an Excel add-in

so
that I can use them as ControlButton images?

I currently use bitmap images saved to the same folder as the add-in, but

I
want to make the add-in more portable by embedding the images in the

add-in
itself.

Thanks.