Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2016

    Unanswered: Excel VBA - Return pictures from another folder based on a dropdown


    Still fairly new user of Excel VBA.
    I have developed a dashboard with a dropdown list displaying the names of staff members from my dpt.
    I would like to dynamically return the pic of the staff selected in the dropdown. The pictures bear the exact same name as the name of the staff +".png" at the end. The pics are saved in a folder on our Q drive.

    Could anyone please help?

    Another question (unrelated to the above): how do you make the VBA to start automatically when a selection is made in the dropdown list (which is supposed to trigger my vba but I can see that I have to also select a random cell afterwards to trigger it which can cause some issues).

    Many thanks and Merry X-mas everybody!

  2. #2
    weejas is offline Grumpy old man (training)
    Join Date
    Sep 2006
    Surrey, UK
    Provided Answers: 17
    To answer the second part first, you'd put the code in the combo box's On Change event (including a check for null values).
    Air code for first part, using the second part as an example:
    Private Sub cmbSelStaffNames_Change()
    Dim strPath As String
    On Error GoTo CSSNC_FDGB
    If cmbSelStaffNames Is Null Then Exit Sub
    strPath = "Q:\Mugshots\" & cmbSelStaffNames.Value & ".png"
    imgMugshot.Source = strPath
    imgMugshot.Visible = True
    Exit Sub
    MsgBox "Error " & Err & " has occurred for staff member " & cmbSelStaffNames.Value & ":" & vbCrLf & Error & vbCrLf & "Please investigate or report.", vbCritical, "Can't find mugshot"
    GoTo CSSNC_Exit
    End Sub
    I haven't worked with varying the source for image objects, so the above might not work, but hopefully it'll steer you in the right direction.
    10% of magic is knowing something that no-one else does. The rest is misdirection.
    Beers earned: 2

  3. #3
    Join Date
    Jan 2017
    you can also insert the picture from drag drop. just pick picture and drag and drop in the excel

Tags for this Thread

Posting Permissions

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