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

Mourouk

New member
Joined
May 31, 2019
Messages
3
Reaction score
0
Points
0
Excel Version(s)
11 for mac version 14.7.7
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
 
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]
 
Hello,

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

M
 
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
 
Back
Top