View Full Version : Insert picture in cell comments

andy wall
09-16-2010, 08:50 PM
I am trying to get a series of pictures to import into a series of excel cells using the comments. I found some code on this site in the knowledgebase from a user named Oorang that I think is what I need: KB ID 102. It is code to automatically insert an image into the comments portion of excel.

But I was wondering if someone might be able to help me apply it to my unique situation.

What I need to do is take cell A1 which contains a link to an image: "www(dot)image(dot)com(slash)image01.jpg" and insert the resulting image into a comment on B1. This needs to be done for A1:B100, with the cell value in A column being a hundred different image links

Is this even doable?

09-17-2010, 12:01 PM
So are you saying that the link in A1 will change 100 times. Or am i reading it wrong? Or is there 100 images you want to fill down column B?

andy wall
09-18-2010, 12:22 AM
hello austenr.
thanks for your response. i need this to work with 100 different images in column A. i did some more digging after i posted and found this solution just in case anyone else needs it:
Sub InsertComment()
Dim rngList As Range
Dim c As Range
Dim cmt As Comment
Dim strPic As String

On Error Resume Next

Set rngList = Range("A1:A5")
strPic = "C:\Data\"

For Each c In rngList
With c.Offset(0, 1)
Set cmt = c.Comment
If cmt Is Nothing Then
Set cmt = .AddComment
End If
With cmt
.Text Text:=""
.Shape.Fill.UserPicture strPic & c.Value
.Visible = False
End With
End With
Next c

thanks again for getting back to me so soon
all the best
End Sub