1. Welcome to Chandoo.org Forums. Short message for you

    Hi Guest,

    Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

    Yours,
    Chandoo
  2. 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...

  3. 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

Discussion in 'VBA Macros' started by Kumar Shanmugam, Aug 10, 2018.

  1. Kumar Shanmugam

    Kumar Shanmugam Member

    Messages:
    154
    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
  2. Chihiro

    Chihiro Excel Ninja

    Messages:
    4,824
  3. Kumar Shanmugam

    Kumar Shanmugam Member

    Messages:
    154
    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).
  4. Kumar Shanmugam

    Kumar Shanmugam Member

    Messages:
    154
    Below link

    Attached Files:

  5. Kumar Shanmugam

    Kumar Shanmugam Member

    Messages:
    154
    Hi Anybody just need code to scale the height and width in excel cell comments
  6. Chihiro

    Chihiro Excel Ninja

    Messages:
    4,824
    Use code tag for code.

    Try something like below. Adjust height & width as needed.
    Code (vb):
    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
     
    Kumar Shanmugam likes this.
  7. Kumar Shanmugam

    Kumar Shanmugam Member

    Messages:
    154

Share This Page