Consulting

Results 1 to 9 of 9

Thread: Show picture in Userform

  1. #1

    Show picture in Userform

    Hi

    I need to show a picture of person in a userform.
    The userform is a employee database.

    I used Application.Match to view data from a spreadsheet in the userform.

    What I now need to do is load the id foto of the person in the image box on my userform.

    I tried the following code (snipped from code found in this website)
    Me.EmplNo is the one i would like to use to match with the picture file
    I named the picture (stored in the same directory) to match the EmplNo field.

    [VBA]Private Sub Show_Pic()

    Dim EmpFound As Range
    Dim fPath As String
    Set EmpFound = Me.EmplNo
    On Error Resume Next
    If EmpFound Is Nothing Then
    Image2.Picture = LoadPicture(fPath & "nopic.gif")
    Else
    With EmpFound
    'Look in the directory where this workbook is located.
    fPath = ThisWorkbook.Path & "\"
    On Error Resume Next
    'If a matching picture is found then display it.
    Image2.Picture = LoadPicture(fPath & "\" & ListBox1.Value & ".jpg")
    'If No picture found then display the default picture.
    If Err = 0 Then Exit Sub
    Image2.Picture = LoadPicture(fPath & "nopic.gif")
    End If
    End With
    End Sub
    [/VBA]

    Please help

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    See http://www.oaltd.co.uk/Excel/Default.htm and scroll down to a file called PastePicture.zip.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    What type of control is Me.EmplNo ?
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  4. #4
    Me.EmplNo is the name of the textbox in the userform

  5. #5
    Someone else was kind enough to make this file to help.
    See if it can be adapted to what you want.

    HTH
    John

  6. #6
    Thanks Jolivanes I will check it out and report back

  7. #7
    Hi guys
    No luck so far using any of the suggestions. I know to little of VBA to explain myself, will try and create a dummy spreadsheet as the information i'm working with is sensitive information.

  8. #8

    Image solution that worked for me

    I had image issues but found a solution. Maybe part of it will help you. My userform is in this post http://www.vbaexpress.com/forum/showthread.php?t=28238&highlight=userform+to+input+data

    Go to llast post for working file (take note of where to put images)

    hope it helps.

  9. #9
    Hi Dodgeitorels
    Thank you for your post, I will let you know if it works for me.

    Regards,
    Leon

Posting Permissions

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