Hyperlink

D

Diego

I need to open a Hyperlink with a macro. I´m using the
following instrution:
Selection.hyperlinks(1).Follow NewWindow:=True,
AddHistory:=True
But the problem is that it only work when the hyperlink
is relationated directly and it doesn´t when I use the
function HYPERLINK(in a worksheet in excel).

Thanks,
 
D

Dave Peterson

What do your =hyperlink() formulas look like:

If they're simply:
=hyperlink("http://yahoo.com")
(no friendly name)

Then you could use something like:

Option Explicit
Sub testme()
With Selection(1)
If .Hyperlinks.Count > 0 Then
.Hyperlinks(1).Follow NewWindow:=True, addhistory:=True
Else
If .Formula Like "=HYPERLINK(*" Then
ActiveWorkbook.FollowHyperlink .Value, _
NewWindow:=True, addhistory:=True
End If
End If
End With
End Sub

If you show a friendly name:

=hyperlink("http://yahoo.com","Click here to go to Yahoo!")

Then you could parse the formula and try to extract just the link info. But if
that link is itself a formula, it could get more complex.

=hyperlink(a1&a2&a3&"//"&b3&".com","who knows?")
for example
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top