Results 1 to 4 of 4

Thread: Insert Pictures automatically in a cell, format the size, then link it.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Neophyte Mourouk's Avatar
    Join Date
    May 2019
    Posts
    3
    Articles
    0
    Excel Version
    11 for mac version 14.7.7

    Insert Pictures automatically in a cell, format the size, then link it.

    Hello, I am a starter.

    I need help.

    I would like to insert pictures in a cell automatically, format it so that it fits to the cell, then link it to the cell.
    But I have 1000 pictures.
    So the idea is to have a sheet open with all the names of the photos as a list in one column
    VBA will read one cell go get it from the Hard disk adjusted then link it with the cell.
    The process will be repeat till I finish the list

    I tried doing it manually but gave up..

    Any input or link who could help me is welcome

    Thank youuuuu

  2. #2
    Acolyte Ron Coderre's Avatar
    Join Date
    Aug 2015
    Location
    Boston, MA
    Posts
    99
    Articles
    0
    Excel Version
    2013, 2016, O365
    This is some code I've had for quite a while....Let me know if it works for you:
    The below code
    loops through each cell in the selected range
    reads the filepath from that cell
    inserts the referenced picture in the cell to the right of the cell:
    resizes the height and width of the picture to the cell's height

    Code:
    Sub InsertPicFromFile()
    Dim cCell As Range
    
    For Each cCell In Selection
        If cCell.Value <> "" Then
            On Error Resume Next
            ActiveSheet.Shapes.AddPicture _
                Filename:=cCell.Value, LinkToFile:=msoFalse, _
                SaveWithDocument:=msoTrue, _
                Left:=cCell.Offset(ColumnOffset:=1).Left, Top:=cCell.Top, _
                Width:=cCell.Height, Height:=cCell.Height
        End If
    Next cCell
    End Sub
    To use that code:
    1)Select a vertical range of cells containing complete paths to picture
    files.
    (Make sure the row heights are large enough to view the pictures.)

    2)Run the macro
    [Alt]+[F8]...to open the macro window
    ...Select: InsertPicFromFile
    ...Click [Run]
    Ron Coderre
    Former Microsoft MVP (2006-2015)

  3. #3
    Neophyte Mourouk's Avatar
    Join Date
    May 2019
    Posts
    3
    Articles
    0
    Excel Version
    11 for mac version 14.7.7
    Hello,

    Thank you so much Ron, I will check this and come back to you.
    I really appreciate.

    M

  4. #4
    Neophyte Mourouk's Avatar
    Join Date
    May 2019
    Posts
    3
    Articles
    0
    Excel Version
    11 for mac version 14.7.7
    Hi Ron,

    Sorry to come back to you. As I said I am a not quite familiar with the operation using macros. I tried to work out but could not manage to do it. I am having hard time.

    This is the exact situation

    The reference name (number) list is in A1 till A1000 for instance .
    The address where I have to pickup the picture is located on the desktop of my Mac where i have a file called "Picture" with JPEg or PNG pictures.
    I need to look at the Reference number in A1, and insert the corresponding pictures.
    The size of the cell is 0.60 inches high and 1.5 inches long so i will need to resize the picture so it fits in the cell while keeping the proportion of the picture..
    Then Link the picture to the cell so I can later use manual method of query.

    Sorry if this is a problem , your help will be appreciated again.

    Many thanks

    M

Posting Permissions

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