Created
June 4, 2014 18:33
-
-
Save jpoehnelt/59060bcf3cac03eff518 to your computer and use it in GitHub Desktop.
Excel VBA: Insert Image into Comment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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