|
楼主 |
发表于 2019-11-10 22:21
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
这是网上找的代码,怎么改成,在桌面上选择某个不特定的单个图片,然后插入到当前鼠标选定单元格里,用批注形式
Private Sub Z803插入A图片批注_Click()
Dim Arr, i&, k&, n&, pd&
Dim PicName$, PicPath$, FdPath$
Dim Rng As Range, Cll As Range
Application.ScreenUpdating = False
On Error Resume Next
'用户选择图片所在的文件夹
Filename = Application.GetOpenFilename(fileFilter:="图片,*.jpg;*.jpeg;*.png;*.bmp;*.wmf;*.jpe,All Files(*.*),*.*")
If Right(FdPath, 1) <> "" Then FdPath = FdPath & ""
Set Rng = Application.InputBox("请选择需要插入图片到批注中的单元格区域", Type:=8)
'用户选择需要插入图片到批注中的单元格或区域
If Rng.Count = 0 Then Exit Sub
Set Rng = Intersect(Rng.Parent.UsedRange, Rng)
'intersect语句避免用户选择整列单元格,造成无谓运算的情况
Arr = Array(".jpg", ".jpeg", ".bmp", ".png", ".gif")
'用数组变量记录五种文件格式
'
Cll.AddComment '增加批注
With Cll.Comment
.Visible = True '批注可见
.Text Text:=""
.Shape.Select True '选中批注图形
Selection.ShapeRange.Fill.UserPicture PicPath & Arr(i)
'插入图片到批注中
.Shape.Height = 150 '图形的高度,可以根据需要自己调整
.Shape.Width = 150 '图形的宽度,可以根据需要自己调整
.Visible = False '取消显示
End With
Application.ScreenUpdating = True
End Sub
|
|