Excel: Code to add picture to Excel Comment: "Ok... so I am not sure of all the medicinal uses of this technology but it is cool. Imagine that you have a list of parts for a product and you want to assign them to cells... then your users could see them as they hover over the cells... I dunno there must be something :s
Anyway, here is the code to do this in VBA (it assumes that the picture name comes from the cell text):
Sub AddPictureToComment()
Dim rng As Range
Dim shp As Comment
Set rng = ActiveCell
If Not rng.Comment Is Nothing Then
rng.Comment.Delete
End If
If rng.Text <> '' Then
Set shp = rng.AddComment('')
shp.Shape.Fill.UserPicture rng.Text
End If
End Sub"
Anyway, here is the code to do this in VBA (it assumes that the picture name comes from the cell text):
Sub AddPictureToComment()
Dim rng As Range
Dim shp As Comment
Set rng = ActiveCell
If Not rng.Comment Is Nothing Then
rng.Comment.Delete
End If
If rng.Text <> '' Then
Set shp = rng.AddComment('')
shp.Shape.Fill.UserPicture rng.Text
End If
End Sub"