I have a macro that imports images from a directory and puts them in excel cells that are made large enough to fit the image in
The macro fragment is shown below: -
'Set the Row Height and Column Width of the thumbnail
Range("A" & CStr(currRow)).RowHeight = ThumbnailSizeRef + 2
Columns("A").ColumnWidth = (ThumbnailSizeRef - 5) / 5 'Column Width uses a font width setting, this is the formula to convert to pixels
'Add the thumbnail
Set sShape = ActiveSheet.Shapes.AddPicture(Filename:=sFilename, LinktoFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=0, Top:=0, Width:=ThumbnailSizeRef, Height:=ThumbnailSizeRef)
'Set the Left and Top position of the Shape
sShape.Left = Range("A" & CStr(currRow)).Left + ((Range("A" & CStr(currRow)).Width - sShape.Width) / 2)
sShape.Top = Range("A" & CStr(currRow)).Top + ((Range("A" & CStr(currRow)).Height - sShape.Height) / 2)
It all works great. Images are displayed correctly in the cell as needed. I can sort the cells successfully and the images move correctly.
The problem is when I delete the entire row of rows (right-click on the row and delete) ... in this situation, the image from the Im line that is deleted is discarded and hides behind the image in the next row.
Is there a way to delete an image when deleting a row?
David source
share