Pages

Saturday, July 16, 2011

Add image as comment to active cell using vba excel

if you would like to select any image and add as a comment to activecell

Here is the code-


Sub test()
Dim s As String
s = Application.GetOpenFilename("Image Files (*.bmp;*.gif;*.jpg;*.jpeg)," & "*bmp;*gif;*.jpg;*.jpeg")
ActiveCell.AddComment.Text "akoul.blogspot.com"
ActiveCell.Comment.Shape.Fill.UserPicture s

End Sub


It will open a folder browse window.Choose any image and will add as comment to activecell.

2 comments:

  1. How can you also set height and width using this as a start?

    ReplyDelete
  2. @McCapo Please try these statements . See if it helps

    ActiveCell.Comment.Shape.Height = 100
    ActiveCell.Comment.Shape.Width = 100

    ReplyDelete