Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Add a Picture to an Excel Comment I\'ve followed the ssteps for adding a picture

ID: 3565328 • Letter: A

Question

Add a Picture to an Excel Comment

I've followed the ssteps for adding a picture to a comment in Excel 2010 as described in answers on this forum, it worrks 100%. I want to include these steps in my code. I Recorded tthe macro, unfortunately this did not work as expected. It looks like the recorder does not record the steps from the time I select "Edit Comment", until I rescale the picture. I've got a sheet with names of employees and the file name of the photo If I insert the picture on the sheet [Inset>Picture] the macro records the steps however I don't seem to find the correct code to include the picture as part of the cell comment in my code. Any assistance will be much appreciated

Explanation / Answer

Hi,

try this sample code

add a picture from a url address, as comment

select a cell and run this code...

Sub URL_PICTURE_AS_COMMENT()

'Oct 07, 2014

On Error Resume Next
Selection.Comment.Delete
Dim pPath As String
pPath = "http://kellysthoughtsonthings.com/wp-content/uploads/2012/12/nature-wallpaper-175.jpg"
With ActiveSheet.Range(Selection.Address).AddComment
.Text ""
.Visible = True
With .Shape
.Fill.UserPicture pPath
.LockAspectRatio = False
.Height = 180
.Width = 240
End With
End With
End Sub

xxxxxxxxxxxxxxxxxxxx

or

try this

if LockAspectRatio =true

select, either height or width

Sub URL_PICTURE_AS_COMMENT_2()

'Oct 07, 2014

On Error Resume Nextt
Selection.Comment.Deletee
Dim pPath As String

With ActiveSheet.Range(Selection.Address).AddComment
.Text ""
.Visible = True
With .Shape
.Fill.UserPicture pPath
.LockAspectRatio = True
.Height = 180
'.Width = 240
End With
End Withh
End Subb

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote