Results 1 to 4 of 4

Adding a Picture to a Userform

This is a discussion on Adding a Picture to a Userform within the Excel Questions forums, part of the Question Forums category; Hi all, I am trying to Create a Button on a userform which is like a "browse" button, so you ...

  1. #1
    Board Regular
    Join Date
    Jul 2007
    Posts
    159

    Default Adding a Picture to a Userform

    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

  2. #2
    Board Regular
    Join Date
    Jul 2007
    Posts
    159

    Default Re: Adding a Picture to a Userform

    Think i have sorted something out....but would still like to know if anyone can do it better!

  3. #3
    MrExcel MVP
    Moderator
    Andrew Poulsom's Avatar
    Join Date
    Jul 2002
    Posts
    64,505

    Default Re: Adding a Picture to a Userform

    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

  4. #4
    Board Regular northwolves's Avatar
    Join Date
    Jun 2006
    Location
    Taiyuan,China
    Posts
    1,115

    Default Re: Adding a Picture to a Userform

    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

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com