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
 
Thanks Alan...

I appreciate any help... I've been struggling with this for countless hours. Yikes.

Corey
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hey Alan... I don't know if you're still out there... but if you were able to come up with something for me... I'd really appreciate it. :)

If not... Is there anyone out there that can help me insert this a picture from a form into a worksheet?
 
Upvote 0
Hi Corey,

Sorry about that - got a little delayed I got into work and guesswhat? they expected me to actually DO something ;¬)

Assuming that the filename of the required picture is in vFilename, try:

Range("C9").select
ActiveSheet.Pictures.Insert( vFileName)
 
Upvote 0
Hey Alan,

Thanks again for your help...

Unfortunately that code doesn't seem to work. I get a run time error?

Here's the full code I've been using for a click on "ok"

Code:
Private Sub cmdOk_Click()
    'unprotect sheet
    ws.Unprotect "123456"
 
    Range("C9").Select
    ActiveSheet.Pictures.Insert (vFileName)

    'protect sheet
    ws.Protect "123456"
   'if close is checked then close form
   If ckClose.Value Then
         Close form
        Me.Hide
    End If
End Sub

I hate to take so much of your time on this... I'm beginning to think this just might not be possible to do. ugh
 
Upvote 0
Morning Corey what's the storey ;¬)

The variable vFileName needs to contain a valid full-path filename.

So if, for instance, you declared vFileName at the top of your userform (AFTER 'Option Explicit' if present), it will be 'in scope' for the OK button code.
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,387
Members
448,957
Latest member
Hat4Life

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