經過各位的提示,問題終于得到了解決!謝謝!
Sub 批量圖片插入最新()
Dim sh As Shape '聲明圖形對象變量,讓圖片適應單元格
Dim x%, y%, i%
Dim t1 As
Dim t2 As
Dim t3 As
Dim t4 As
Dim As
Dim As
Dim As
For i = 1 To ..(.Range("D:D")) - 1
t1 = (4).Cells(i + 4, 3) & "免冠"
t2 = (4).Cells(i + 4, 3) & "身份證1"
t3 = (4).Cells(i + 4, 3) & "身份證2"
t4 = (4).Cells(i + 4, 3) & "特1"
For x = 1 To ...Rows.Count
For y = 1 To ....Count
= .Cells(x, y).Value & ".jpg"
Set = (".")
If .(.Path & "\員工照片\" & ) = False Then
' .Path & "\員工照片\" & & "圖片不存在"
Else '在選定的單元格中插入圖片
If Cells(x, y) = t1 Or Cells(x, y) = t2 Or Cells(x, y) = t3 Or Cells(x, y) = t4 Then
With (5)
.Cells(x, y).
..(.Path & "\員工照片\" & ).
.. =
.Left = .Cells(x, y)..Left
.Top = .Cells(x, y)..Top
.Width = .Cells(x, y)..Width
. = .Cells(x, y)..
End With
End If
End If
Next y
Next x
Next i
End Sub