How do I insert a PictureBox into Excel?

G

Guest

I don't know much about VBA. Is there any way to easily insert a PictureBox
into an Excel worksheet so that a .jpg file can be selected from a directory
of .jpg files and loaded to the worksheet?

Thanks,

Evanbron
 
G

Guest

Hi,
Just off-hand, You could use a userform with an image control, a list box
with a list of the picture locations and a button to insert picture into the
image control. If the desired pictured is acceptable, use another button to
insert the picture into the worksheet.

If you would like me to create this project for you, you can send me the
relevant info.
See my user stuff at http://www.geocities.com/excelmarksway

- Mark
PS I just might do it anyhow and post it to my Excel site in a couple of
days...
 
R

Rowan Drummond

This will place the picture on the sheet at the currently selected cell.

Sub JPeg()
Dim flname As Variant
flname = Application.GetOpenFilename
If flname <> False Then
If Right(flname, 3) = "jpg" Then
ActiveSheet.Pictures.Insert (flname)
Else
MsgBox "That is not a jpeg file"
End If
End If
End Sub

Hope this helps
Rowan
 
G

Guest

Hi,
Rowan's answer is good. I have implemented the same macro to a userform
utility.
Here is how it works:
Click the Open Folder Picture button to show the Open Dialog
Click Cancel when you have found the Folder you want. The Open Dialog does
not open any files should you click the OPEN button.
The file types have been preset in the Open Dialog.
The Folder Location textbox shows your selected Folder of Picture Files.
The File Type combobox shows you the type of file types allowed for the
image control.
The Files in the Current Folder listbox shows the compatible files. Click an
item in the listbox to load it into the image control.
Insert Picture button inserts the selected picture into the current active
worksheet.
The Hide Pic Box button allows you to hide the main form so you can get a
better view of the inserted picture. A small form is shown at the Top-Left of
your screen so you can reload the main form when you are ready.
Also, I have resized the picture to approx. 1/3 the original size. Good for
large pictures, no good if you import an icon or small picture...
You can download it from http://www.geocities.com/excelmarksway
(e-mail address removed)
24 October 2005
 

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