
1、打开Excel,点击“打开其他工作薄”选项,然后选择Excel工作簿所在的位置将其打开
2、在打开的Excel工作表中,任意选中一个单元格点击它。然后再点击菜单选项栏的“审阅”,在审阅选项卡的“批注”分区功能区中点击“新建批注”选项
3、这个时候单元格右侧会d出批注对话框,我们可以在批注框中输入文字信息
4、在批注框边框上点击鼠标右键,在d出的菜单列表选项中,点击“设置批注格式”选项
5、在d出的“设置批注格式”对话框中,切换到“颜色与线条”选项卡,点击“填充”颜色右侧的小三角箭头,在下拉菜单中选择“填充效果”选项
6、在d出的填充效果对话框中,切换到图片选项卡,点击“选择图片”按钮。从本地选取一张图片打开。最后点击“确定”按钮
Sub pztp()
On Error Resume Next
Dim c As Range, P$, i&, a$, b$, arr, w!
P = "F:\唐狮图片\唐狮图片\"
For Each c In Range([c2], Cells(Rows.Count, 3).End(3))
With c
.ClearComments
.AddComment
.Comment.Shape.Fill.UserPicture P & .Value & ".jpg"
a = get_file_dim(P & .Value & ".jpg")
For i = 1 To Len(a)
If Mid(a, i, 1) Like "[0-9x]" Then
b = b & Mid(a, i, 1)
End If
Next
arr = Split(b, "x")
b = ""
w = 200 '设置图片宽度
.Comment.Shape.Width = w
.Comment.Shape.Height = Val(arr(1)) / Val(arr(0)) * w
End With
Next
End Sub
Function get_file_dim(ByVal filepath As String)
arr = [{161,162,163,164,31}]
Dim brr(), sz, i As Byte
ReDim brr(1 To UBound(arr))
Set ObiFolder = CreateObject("shell.Application").Namespace(Left(filepath, InStrRev(filepath, "\")))
For i = 1 To UBound(arr)
sz = ObiFolder.getdetailsof(ObiFolder.Items.Item(Right(filepath, Len(filepath) - InStrRev(filepath, "\"))), arr(i))
If sz Like "*[0-9] x [0-9]*" Then
get_file_dim = sz
Exit For
End If
Next i
End Function
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)