Ai答复
Sub InsertPicturesUsingDir()
Dim picPath As String
Dim picFile As String
Dim ws As Worksheet
'设置要操作的工作表
Set ws = ActiveSheet
'指定图片文件夹路径
picPath = "C:\Your\Folder\Path\" '请将此处替换为实际的图片文件夹路径
picFile = Dir(picPath & "*.*")
Do While picFile <> ""
If LCase(Right(picFile, 3)) = "jpg" Or LCase(Right(picFile, 3)) = "png" Or LCase(Right(picFile, 4)) = "jpeg" Then
ws.Pictures.Insert(picPath & picFile).Select
End If
picFile = Dir
Loop
Set ws = Nothing
End Sub