不考虑速度,纯粹插入图片,用VBA代码见下: 条件:品名在A列,图片大小最好一致,图片格式为JPG,进入excel后按alt +F11,在模块中粘贴以下代码后按F5执行。
sub insert_pic()
ipath = "D:\TUPIAN" '放置图片的文件夹
With ActiveSheet
i = 0 '如果不是第一行开始,而是第二行开始的话 i=1,其他依此类推
10 i = i + 1
If .Cells(i, 1) = "" Then Exit Sub
Rows(i + 1).Insert
.Cells(i + 1, 2).Select
Rows(i + 1).RowHeight = 100 '行高根据你图片的大小设定,要不插入的图片会遮住你的文件名
.Pictures.Insert (ipath & "\" & .Cells(i, 1) & ".jpg").Select
Selection.ShapeRange.ScaleHeight 0.2, msoFalse, msoScaleFromTopLeft '图片太大可以设缩小,0.2是缩小到20%,
i = i + 1
GoTo 10
End With
end sub