Adding a Picture to a Userform

Submersed

Board Regular
Joined
Jul 6, 2007
Messages
167
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I am trying to Create a Button on a userform which is like a "browse" button, so you click the button and then you can go through and select a picture which will then input the picture into the userform.

Is there anyways i can do this?

thanks
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Think i have sorted something out....but would still like to know if anyone can do it better!
 
Upvote 0
Insert a UserForm with a CommandButton and an Image control. Then try:

Code:
Private Sub CommandButton1_Click()
    Dim FName As Variant
    FName = Application.GetOpenFilename(FileFilter:="Pictures,*.jpg", Title:="Select a Picture", MultiSelect:=False)
    If FName <> False Then
        Image1.Picture = LoadPicture(FName)
    End If
End Sub
 
Upvote 0
Try(Without testing):

Code:
Private Sub CommandButton1_Click()
Dim p
p = Application.GetOpenFilename("Image Files (*.bmp;*.jpg;*.gif), *.bmp;*.jpg;*.gif", , "Please select an image file")
If p <> False Then Me.Picture = LoadPicture(p)
End Sub

Regards
Northwolves
 
Upvote 0

Forum statistics

Threads
1,214,422
Messages
6,119,396
Members
448,891
Latest member
tpierce

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