' a列为图片名c列显示图片
Sub insertPic()
Dim i As Integer
Dim FilPath As String
Dim rng As Range
Dim s As String
With Sheets("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
参考一下
确实是个难题呀