Adding a URL link into a comment within VBA

Viewed 236

I want my code in VBA to set a comment within a cell with a clickable URL iside it. I can do this manually like this:
1) Click in the cell and then insert a comment as "http://www.google.com.br"
2) Right click at the comment cell, and select Show/Hide Comments to show the comment.
Done, the cell is set as a comment showing a clickable hyperlink.

What I tried within VBA:

Sheets(1).Range("H2").AddComment "http://www.google.com.br"
Sheets(1).Range("H2").Comment.Visible = True
Range("H2").Comment.Shape.Select True

But this does not make the cell as an hyperlink. I still have to Select the comment and then select another cell to make it appears as a clickable link.

I also tried:

Dim shp as Shape
With Range("H2")
    .AddComment
    .Comment.Visible = True
    Set shp = .Comment.Shape
End With
ActiveSheet.Hyperlinks.Add Anchor:=shp, Address:="", _
                   SubAddress:="A7", ScreenTip:="Move"

But still I can't make it work in VBA.

Thanks for your help!

0 Answers
Related