Image Into Excel
Image Into Excel
' Set the parent folder path where your subfolders are located
parentFolder = "D:\Office\Pictures Footwears AlNasser\" ' Update this path
' Find the column number for the "Picture" column by searching for the header
pictureColumn = 0
For Each cell In ws.Rows(1).Cells ' Search in the first row
If cell.Value = "Picture" Then
pictureColumn = cell.Column
Exit For
End If
Next cell
' Initialize the imgPath variable to an empty string for each iteration
imgPath = ""
' If a matching image is found, insert and embed the image into the
"Picture" column
If imgPath <> "" Then
' Insert the image as an embedded object using Shapes.AddPicture
Set img = ws.Shapes.AddPicture( _
Filename:=imgPath, _
LinkToFile:=msoFalse, _
SaveWithDocument:=msoCTrue, _
Left:=cell.Offset(0, pictureColumn - 1).Left, _
Top:=cell.Offset(0, pictureColumn - 1).Top, _
Width:=-1, Height:=-1)