Sub InsertPicture()
Dim MyShape As Shape
Dim r As Integer
Dim c As Integer
Dim PicPath As String
Dim Picrng As Range
With Sheet1
For Each MyShape In .Shapes
If MyShape.Type = 13 Then
MyShape.Delete
End If
Next
For r = 2 To .Cells(.Rows.Count, 1).End(xlUp).Row
For c = 1 To 8 Step 2
PicPath = ThisWorkbook.Path & "\" & .Cells(r, c).Text & ".jpg"
If Dir(PicPath) <> "" Then
Set MyShape = .Shapes.AddPicture(PicPath, False, True, 6, 6, 6, 6)
Set Picrng = .Cells(r, c + 1)
With MyShape
.LockAspectRatio = msoFalse
.Top = Picrng.Top + 1
.Left = Picrng.Left + 1
.Width = Picrng.Width - 1.5
.Height = Picrng.Height - 1.5
.TopLeftCell = ""
End With
Else
.Cells(r, c + 1) = "暂无照片"
End If
Next
Next
End With
Set MyShape = Nothing
Set Picrng = Nothing
End Sub
效果如下图: