Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbCode to Link a Picture to User Form

Status
Not open for further replies.

arresteddeveloper

Technical User
Aug 26, 2004
1
US
I have a workbook that uses a lot of user forms. Some of the user forms display pictures. I want to use jpegs to cut down the size of my workbook but excel defaults the userform picture as a bitmap and my workbook size is huge. Is there a way around this and make them jpegs? I thought maybe I could use code to LINK the photo to the user form rather than embed it onto the user form.

Anyone have any suggestions? Thanks a lot!!!
 
Yes it defaults the userform picture as a bitmap...I hate to tell you this, jpegs ARE bitmaps. As are TIFF, BMP, and anything else that uses bits to map pixel dimensions on screen. There is no problem using jpegs on userforms.

You can dynamically load images to a userform with LoadPicture, as in:

Image1.Picture = LoadPicture("c:\DigitalPics\somefile.jpg")

As for linking, as opposed to embedding, you could have the images load on userform Initialize. That way, they would load as the userform starts up, and would not have to be in the file itself. This would keep the file size down. To retain that, make sure you unload the image on closing the userform, as in:

Image1.Picture = LoadPicture("")

This removes the image from memory, and it will not be retained in the file.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top