第1个回答 推荐于2016-09-03
Sub insertPic()
Dim i As Integer
Dim FilPath As String
Dim rng As Range
Dim s As String
With Sheet1
For i = 3 To .Range("a65536").End(xlUp).Row
FilPath = ThisWorkbook.Path & "\" & .Cells(i, 1).Text & ".jpg"
If Dir(FilPath) <> "" Then
.Pictures.Insert(FilPath).Select
Set rng = .Cells(i, 3)
With Selection
.Top = rng.Top + 1
.Left = rng.Left + 1
.Width = rng.Width - 1
.Height = rng.Height - 1
End With
Else
s = s & Chr(10) & .Cells(i, 1).Text
End If
Next
.Cells(3, 1).Select
End With
If s <> "" Then
MsgBox s & Chr(10) & "没有照片!"
End If
End Sub本回答被提问者采纳