gpt4 book ai didi

vba - 添加图像作为评论 VBA

转载 作者:行者123 更新时间:2023-12-04 21:12:55 25 4
gpt4 key购买 nike

我发现此代码可将图像插入到 excel 2013 中,但图像比它们要进入的单元格大。我认为将图像加载为评论的最佳选择。

有人可以在下面修改此 VBA 以将其添加为评论吗?

Sub URLPictureInsert()
Dim cell, shp As Shape, target As Range
Set rng = ActiveSheet.Range("R2:R5") ' range with URLs
For Each cell In rng
filenam = cell
ActiveSheet.Pictures.Insert(filenam).Select

Set shp = Selection.ShapeRange.Item(1)
With shp
.LockAspectRatio = msoTrue
.Width = 50
.Height = 50
.Cut
End With
Cells(cell.Row, cell.Column + 5).PasteSpecial

Next

End Sub

最佳答案

我相信以下链接有你正在寻找的东西

http://en.kioskea.net/faq/8619-excel-a-macro-to-automatically-insert-image-in-a-comment-box

Sub Img_in_Commentbox()  
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = False 'Only one file
.InitialFileName = CurDir 'directory to open the window
.Filters.Clear 'Cancel the filter
.Filters.Add Description:="Images", Extensions:="*.jpg", Position:=1
.Title = "Choose image"

If .Show = -1 Then TheFile = .SelectedItems(1) Else TheFile = 0
End With
'No file selected
If TheFile = 0 Then
MsgBox ("No image selected")
Exit Sub
End If
Range("A1").AddComment
Range("A1").Comment.Visible = True
[A1].Comment.Shape.Fill.UserPicture TheFile
End Sub

关于vba - 添加图像作为评论 VBA,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21396983/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com