+ Reply to Thread
Results 1 to 5 of 5

Display Photo from Folders

Hybrid View

  1. #1
    Registered User
    Join Date
    04-25-2011
    Location
    pgh
    MS-Off Ver
    Excel 2003
    Posts
    16

    Display Photo from Folders

    Ok so I have research many options and cant get one to work. What I have is a dropdown menu and based on which value is selected I want a photo displayed.

    What I have right now is the main sheet with a dropdown and a 2nd sheet with a table of the dropdown values in one column and the matching file location. I want these in a folder so if someone needs to update a photo they can make a new file with the same name and just copy it into the folder without messing with excel. I have it set up so when the dropdown is selected, below it is a cell that shows the file location (I'll hide this once it works) and I was trying to just have a macro or vb code to use that to display the photo.

    I had it set up prior to work with photos on that 2nd sheet but trying to convert. I attached a demo below. Thanks for any help

    Photo Demo.xlsm

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Display Photo from Folders

    Hello rck3,

    I have added the the Worksheet_Change macro to the attached workbook. The picture will be loaded, if it can be located, into an Image Control on the "Home" worksheet.

    Private Sub Worksheet_Change(ByVal Target As Range)
    
        Dim PicPath As Variant
        Dim Rng     As Range
        Dim RngEnd  As Range
        
            If Target.Cells.Count > 1 Then Exit Sub
            If Intersect(Target, Range("C2")) Is Nothing Then Exit Sub
        
            With Worksheets("Home Data")
                Set Rng = .Range("A2")
                Set RngEnd = .Cells(Rows.Count, Rng.Column).End(xlUp)
                If RngEnd.Row < Rng.Row Then Exit Sub
                Set Rng = .Range(Rng, RngEnd)
            End With
        
                Application.EnableEvents = False
                    Set PicPath = Rng.Find(Target.Value, , xlValues, xlWhole, xlByRows, xlNext, False, False, False)
                    
                    If PicPath Is Nothing Then
                        PicPath = ""
                    Else
                        PicPath = PicPath.Offset(0, 1).Value
                    End If
                    
                On Error Resume Next
                    ActiveSheet.OLEObjects("Image1").Object.Picture = LoadPicture(PicPath)
                Application.EnableEvents = True
                
    End Sub
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    04-25-2011
    Location
    pgh
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Display Photo from Folders

    Thanks, that's what I was looking for. 1 issue is with photo sizing. I know I can adjust the photo box but I would like to have the image resize to fit the area. Right now its displaying a small section of the overall photo. Is this in the image properties or will it need to be done via the macro settings?

  4. #4
    Registered User
    Join Date
    04-25-2011
    Location
    pgh
    MS-Off Ver
    Excel 2003
    Posts
    16

    Re: Display Photo from Folders

    Nevermind, I found the property setting field for it. All good. Thanks!

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Display Photo from Folders

    Hello rck3,

    Glad you found it. For those of you who may want to know, you can set the AutoSize property to True.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Create folders and Sub folders and Sub-Sub folders from 5 columns with VBA
    By arleutwyler in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-11-2014, 04:16 PM
  2. Display or List Special Folders Locations in Excel VBA
    By TMS in forum Tips and Tutorials
    Replies: 0
    Last Post: 02-14-2014, 07:37 AM
  3. [SOLVED] H Lookup in different folders - display whole column
    By Simon1990 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-13-2013, 10:36 PM
  4. Vlookup can use for display photo?
    By raveepoojari in forum Excel General
    Replies: 12
    Last Post: 06-16-2011, 12:08 PM
  5. change display format for excel folders and files
    By inthestands in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-15-2006, 08:10 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1