ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Adding a hyperlink to a shape (https://www.excelbanter.com/excel-programming/363852-adding-hyperlink-shape.html)

Rand[_2_]

Adding a hyperlink to a shape
 
I have been trying to add a hyperlink to a shape using the following in
Excel 2002:


ActiveSheet.Shapes("Object 1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection.ShapeRange.Item(1),
Address:= _
"http://www.cas.org/"

This code was generated by recording a macro. The hyperlink was successfully
added during the recording, and works just fine.

However, when I run this recorded macro, I get a:

Run-time error '5':
Invalid procedure call or argument

After a little experimentation, I found I can add a Range object as an
Anchor, but not a Shape object as the documentation indicates that I should.

Does anyone have a solution to this problem?

Thanks,

Rand



Tim Williams

Adding a hyperlink to a shape
 
ActiveSheet.Hyperlinks.Add Anchor:=ActiveSheet.Shapes("Object 1"), _
Address:="http://www.cas.org/"

--
Tim Williams
Palo Alto, CA


"Rand" wrote in message ...
I have been trying to add a hyperlink to a shape using the following in
Excel 2002:


ActiveSheet.Shapes("Object 1").Select
ActiveSheet.Hyperlinks.Add Anchor:=Selection.ShapeRange.Item(1),
Address:= _
"http://www.cas.org/"

This code was generated by recording a macro. The hyperlink was successfully
added during the recording, and works just fine.

However, when I run this recorded macro, I get a:

Run-time error '5':
Invalid procedure call or argument

After a little experimentation, I found I can add a Range object as an
Anchor, but not a Shape object as the documentation indicates that I should.

Does anyone have a solution to this problem?

Thanks,

Rand






All times are GMT +1. The time now is 02:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com