The below code checks to see if an Image path is found (K39).
If it does the Image is placed into cell F40.
The rest of the code basically modifies the size of the image to suit, but for some reason the re-sizing code does not work.
Sub REPOPULATEIMAGES()
' PHOTO 1
If Sheets("REPORT").Range("K39").Value <> "" Then
Sheets("REPORT").Range("F40").Select
Dim WB As Workbook
Dim SH As Worksheet
Dim rng As Range
Dim myPic As Picture
Dim res As Variant
Set WB = ActiveWorkbook
res = Sheets("REPORT").Range("K39").Value
Set SH = ActiveSheet
Set rng = Sheets("REPORT").Range("F40")
On Error Resume Next
Set myPic = SH.Pictures.Insert(res)
With myPic
.Top = rng.Top + 2 ' <=== Not working
.Left = rng.Left + 2 ' <=== Not working
myPic.ShapeRange.LockAspectRatio = msoFalse
myPic.ShapeRange.Height = 145# ' <== Not working
myPic.ShapeRange.Width = 200# ' <=== Not working
myPic.ShapeRange.Rotation = 0#
myPic.Name = "PHOTO1"
End With
End If
End Sub
However,
when using the above code to originally insert the image, and place the file path in the cell, the sizing works as expected.
Bookmarks