• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

how to automate display of pictures using comments with vba also scale height and width

Hi I am trying to use below code but I am getting error 438

Objective. is to automate display of pictures using comments with vba. I am getting images displayed against C2 cell but I cannot adjust its scale height and width.

VBa code:

Sub showPic()

For Each cell In Selection
MyPicture = "F:\Pictures_airmore_20180807_074658\" & cell.Value & ".png"
With cell.AddComment
.Shape.Fill.UserPicture MyPicture
.ShapeRange.ScaleWidth.UserPicture MyPicture = 2.92, msoFalse, msoScaleFromTopLeft
.ShapeRange.ScaleHeight.UserPicture MyPicture = 3.22, msoFalse, msoScaleFromTopLeft
End With
Next cell
End Sub


This is my workbook. Problem is with scale height and width in below vba code. I don't know how to fix it.

upload_2018-8-10_7-55-31.png

Vba code:

upload_2018-8-10_7-57-12.png
 
Hi Chihiro thanks for sharing the link.

However I want to continue with the code provided in youtube link :


Code is below:
Sub showPic()
For Each cell In Selection
MyPicture = "C:\Users\takyar\Pictures\PillowCases\" & cell.Value & ".jpg"
With cell.AddComment
.Shape.Fill.UserPicture MyPicture
End With
Next cell
End Sub

Just searching for the code that will also help me to scale the height and width in excel cell comments. (which is not there in the above code).
 
Use code tag for code.

Try something like below. Adjust height & width as needed.
Code:
Sub showPic()
For Each cell In Selection
MyPicture = "C:\Users\takyar\Pictures\PillowCases\" & cell.Value & ".jpg"
With cell.AddComment
.Shape.Fill.UserPicture MyPicture
End With
With cell.Comment.Shape
    .Width = 300
    .Height = 500
End With
Next cell
End Sub
 
Back
Top