I'm new to VBA. I have an Excel file where in column A there is product number (ie 12345, 12346 etc); I want the attached picture from the web as the comment in the specific cell with item number.
Picture on the web is on https://www.website.com/picture/12345.jpg
.
I have multiple product numbers in column A.
I did come up with something like that but this is not working.
Sub InsertMultipleCommentWithPicture()
Dim i As Long
Dim LastRow As Long
Dim CommentRange As Range
Dim Pic As Object
Dim PicURL As String
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To LastRow
Set CommentRange = Cells(i, 1)
PicURL = "https://www.website.com/picture" & Cells(i, "A").Value & ".jpg"
Set Pic = CreateObject("Scripting.FileSystemObject").GetFile(PicURL)
CommentRange.AddComment
With CommentRange.Comment
.Shape.Fill.UserPicture Pic.Path
.Shape.Width = Pic.Size * 0.01
.Shape.Height = Pic.Size * 0.01
End With
Next i
End Sub
type here
Does someone already have something similar which can do this as I'm lost.
I did tried above code and some codes from internet however none of them working.
I need have the picture from website attached as the comment not inserted in the cell.
It will be good if there will be option to size up the comment box to specific size.