Results 1 to 3 of 3

How to import multiple picture files from folder using cell values for an entire column

Threaded View

dlac How to import multiple... 01-30-2013, 03:05 PM
Mantorok Re: How to import multiple... 03-23-2013, 02:51 AM
Wormsek Re: How to import multiple... 03-23-2013, 04:17 AM
  1. #1
    Registered User
    Join Date
    01-24-2013
    Location
    Boston, MA
    MS-Off Ver
    Excel 2003
    Posts
    3

    How to import multiple picture files from folder using cell values for an entire column

    Hey all,

    Leith Ross put together the code and xls below to pull an image into an excel sheet and place it to the right of A1 if the filename in a designated folder matched the text in A1. (as a response in this thread)

    Is there a way to have this functionality work down the entirety of A:A?

    I'm imagining that the picRange would be B1 instead (or B#, just the cell next to the relevant A column) and I'd just set a tall row height, so that the pictures are exactly within the cells in B:B next to the filename text.

    Is this possible? Any help would be greatly appreciated


    Worksheet_Change Event Macro Code
    
    Private Sub Worksheet_Change(ByVal Target As Range)
    
        If Target.Cells.Count > 1 Then Exit Sub   
        If Target.Address <> "$A$1" Then Exit Sub
        
            Call ImportPicture(Target.Value)
        
    End Sub
    Import Picture To Range Macro Code
    
    Sub ImportPicture(ByVal Filename As String)
    
        Dim Filepath As String
        Dim Pic As Shape
        Dim PicName As String
        Dim PicRange As Range
                
               Set PicRange = ActiveSheet.Range("C2:E14")
               
               PicName = PicRange.Cells(1, 1)
               If PicName <> "" Then ActiveSheet.Shapes(PicName).Delete: PicRange.Cells(1, 1) = ""
               
               Filepath = "C:\Documents and Settings\User\Desktop\Pictures\"
               Filename = Filepath & ActiveCell & ".jpg"
                
                If Dir(Filename) = "" Then Exit Sub
                
                With PicRange
                    Set Pic = ActiveSheet.Shapes.AddPicture(Filename, msoFalse, msoTrue, .Left, .Top, .Columns.Width, .Rows.Height)
                    PicRange.Cells(1, 1) = Pic.Name
                End With
                
    End Sub
    Attached Files Attached Files
    Last edited by dlac; 01-30-2013 at 05:41 PM.

Thread Information

Users Browsing this Thread

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

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