User Form (Inserting a Picture)

leadx

Board Regular
Joined
Oct 24, 2004
Messages
93
I'm looking to use a user form to insert a picture into excel.

The picture area would be 2" x 2", but a user would able to enter a smaller picture.

So... I'm wondering if this is even possible and how the heck you'd code something like this... my vba skills are still in the elementary stage. :)

Thanks in advance,

Corey
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Corey

How exactly would the user be entering a picture?
 
Upvote 0
Well I was hoping they be able to enter the picture through a user form... So they could use a browse button... or is it possible to create a macro that brings up the insert picture dialog box and then insert the picture into the allocated space?
 
Upvote 0
Hi,

Try:
Code:
Dim vFileName As Variant

vFileName = Application.GetOpenFilename("Bitmap files (*.bmp), *.bmp,Gif files (*.gif),*.gif")
If vFileName = False Then Exit Sub

Image1.Picture = LoadPicture(Filename:=vFileName)

assuming your Image control is called 'Image1'

PS

Morning Norie,what's the storie? ;¬)
 
Upvote 0
That's al_b_cnu

That worked awesome for brining up the dialog box.

I'm a little confused by one thing... What do you mean by:
"assuming your Image control is called 'Image1' "

I'm still learning vba and don't really understand this... How do I create an Image Control?

Many Thanks... really appreciate your help.

Corey
 
Upvote 0
Hi corey,

To create an image control, just click on the 'Image' icon in the toolbox & drag & draw onto the userform, the default name will be 'Image1'.

If no Image icon is visible (looks like a picture of a mountain with the sun), in 'Additional controls', ensure that 'Microsof Forms Image' is selected.

You will probably want to set the PictureSizeMode to '3 - fmPictureSizeModeZoom'
 
Upvote 0
Thanks again Alan,

Everything is working great... Thanks for the tip on using fmPictureSizeModeZoom' as well. Make any picture fit the Image box perfect.

I just have one last little challenge.... I know how to enter data from a from into a worksheet, but I'm a little lost when it comes to an image.

I've been trying to use:
Code:
ws.Cells(9, 2).Image1.Picture

I keep getting numbers inserted instead of the picture... Is there a special way to insert a picture?

Many Thanks,

Corey[/code]
 
Upvote 0
Hey Alan,

Thanks for the link... I've been reading through both threads but I can't seem to find a solution to my challenge.

Just to be clear... below is a picture of my userform:

microsoft_windows_xp-20070720-080754.jpg


The browse button... is coded with the code you provided my to insert the picture in the form...

My problem is I need to figure a way to get this picture into the sheet with the top right corner starting in cell C9.

I can't seem to find the right solution to this... do you know a solution for this?

Thanks again,

Corey
 
Upvote 0
Hi Corey,

I'm going to be rather busy all weekend,but will have a look on Monday morning if no-one has come up with a solution for you.

Doesnt seem too difficult though.

Alan

PS Nice house!
 
Upvote 0

Forum statistics

Threads
1,214,873
Messages
6,122,029
Members
449,061
Latest member
TheRealJoaquin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top