Embed Pictures in Workbook

  • Thread starter Thread starter John Wilson
  • Start date Start date
J

John Wilson

Was wondering if there was a way to do this????

This is what I have to display a selected picture in a UserForm:

Image1.Picture = LoadPicture("I:\2004 Yankees Schedule\Logos\" & _
Label1.Caption & ".jpg")

With the above, I can display the .jpg that's associated with the
caption in Label1. If Label1.Caption = "Oakland", it'll display
the oakland.jpg as the Image picture.

What I'd like to be able to do is have those .jpg's included in the
workbook and still be able to achieve the same functionality.
Not worried about the size of the workbook as all 30 jpg's
only add up to about 180 kB.

Any ideas??

Thanks,
John
 
You might have a look at Stephen Bullen's site and see the code for the
pastepicture.zip file

http://www.bmsltd.ie/Excel/Default.htm

look all the way down under the VBA section. Here is the writeup. Sounds
like what you want to do - paste from the clipboard into an image control.

The userforms in Excel 97 are great, apart from one BIG letdown - you can't
put charts on them! A kludgy workaround has been to export the chart as a
gif or jpg, then load it into an Image control using LoadPicture. That
works ok-ish for charts, but it can't handle word art, shapes or other
pictures created on the fly. This file includes code to create a Picture
object from whatever is on the clipboard. Display a chart on a userform is
now as easy as a copy/paste. Thanks to VB MVPs Karl Peterson, Randy Birch
and Brad Martinez for their help. You can paste the image as either a
bitmap (better for same-size copies) or a metafile (better when
zooming/stretching), whichever best suits your circumstances. This update
includes an example of saving the picture to disk as a bitmap or metafile.
 
Tom,

I tried Steve's file and still can't get this to work.
There is the distinct possibility that some of my synapses aren't
firing correctly.

Would've thought that it would be easier to link an Image control
to a picture saved directly in the workbook than it would be to link
to a picture somewhere on the hard drive but obviously, that isn't
the case. :-(

Forgetting the fact that I would want to change these pictures
programmatically, how would I link a single embedded picture
to an image control on a UserForm?

Example:
Took a small picture. Copied and pasted it from "Paint" to Sheet1
of a workbook. Excel named it "Object 1" and the formula bar
shows it as
=EMBED("Paint.Picture","")

How do I get that Picture, Object, OLEObject, whatever the heck it
is to display on Image1 in UserForm1???

Thanks,
John
 
Tom,

Reconnected a few (not all) of my synapses, cleansed them with
some alchohol (drinking, not rubbing) and got it to work using
Stephen's coding.

Thanks,
John
 
Back
Top