在单元格的批注中添加背景图片
Sub 给单元格批注添加背景图片()
Dim lj$, i As Long, file$
[a2:a9999].Clear
lj = "E:\刘卓\个人资料\Excel资料\素材图片" '文件夹路径
file = Dir(lj & "\") '用dir函数提取路径下的第1个文件名
Do While file <> "" '如果文件名不为空,则进入do...loop循环
i = i + 1 '文件数累加1
With Cells(i + 1, 1)
.Value = file '将文件名写入对应的单元格中
.AddComment '在单元格中添加批注对象
.Comment.Shape.Fill.UserPicture lj & "\" & file '在批注中填充背景图片
.Comment.Shape.Height = 80 '设置批注图形的高度
.Comment.Shape.Width = 80 '设置批注图形的高度
End With
file = Dir '用不带参数的dir遍历后面的文件
Loop
With Range("a1").CurrentRegion 'a1单元格的当前区域
.Borders.LineStyle = xlContinuous '设置边框
.HorizontalAlignment = xlCenter '水平居中对齐
.VerticalAlignment = xlCenter '垂直居中对齐
End With
End Sub
https://pan.baidu.com/s/1NVsa9ISNYQu8dClIlfr_ow
赞 (0)