excel插入图片链接,显示图片
作者:互联网
Sub test()
Dim rg As Range, shp As Shape
Rem ---------------------------------------------------
Rem 清除图形对象
For Each shp In ActiveSheet.Shapes
shp.Delete
Next
Rem ---------------------------------------------------
Rem 按名称插入图片
Rem 下行代码,根据A列开始循环处理
Rem 遇到错误继续执行 Cells(Rows.Count, "A").End(3).Row
On Error Resume Next
For i = 2 To 8
Set rg = Cells(i, "K")
Rem 下面代码,添加矩形
ActiveSheet.Shapes.AddShape(msoShapeRectangle, rg.Left, rg.Top, rg.Width, rg.Height).Select
Rem 下面代码,在矩形内部用图片填充
Rem Selection.ShapeRange.Fill.UserPicture "E:\图片\" & rg.Offset(0, -1) & ".jpg"
Selection.ShapeRange.Fill.UserPicture rg.Offset(0, -1)
Next
End Sub
标签:End,Sub,ActiveSheet,excel,插入,rg,Rem,图片链接,图片 来源: https://www.cnblogs.com/yc-shen/p/14142054.html