Skip to content

Instantly share code, notes, and snippets.

@jpoehnelt
Created June 4, 2014 18:33
Show Gist options
  • Save jpoehnelt/59060bcf3cac03eff518 to your computer and use it in GitHub Desktop.
Save jpoehnelt/59060bcf3cac03eff518 to your computer and use it in GitHub Desktop.
Excel VBA: Insert Image into Comment
Sub InsertPictures()
' Variable Declarations
Dim cll As Range
Dim rng As Range
Dim strPath As String
' Path to photos
strPath = "D:\Photo Folder"
' Set the range
Set rng = Range("B2:B" & Range("b" & Rows.Count).End(xlUp).Row)
' Set the comments to contain photo
For Each cll In rng
With cll
On Error Resume Next
.ClearComments
.AddComment ("")
.Comment.Shape.Fill.UserPicture (strPath & "\" & cll.Value & ".jpg")
.Comment.Shape.height = 200
.Comment.Shape.Width = 300
End With
Next cll
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment