Hyperlink Construction and Execution

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I built a hyperlink in a cell that works fine when I click on the cell that
looks like this

=HYPERLINK(CONCATENATE("http://",'Toolkit Setup'!$A$16,"/",'Toolkit
Setup'!$M$12),"Agent "&'Toolkit Setup'!$M$12&" WEB Site")

In a macro I am trying to execute this but it fails with a subscript out of
range on the Selection.Hyperlinks(1).Follow

' If no Agent web site then Alert and Exit
If [A17] <> "" Then
Range("A17").Select
Selection.Hyperlinks(1).Follow
GoTo Exit_1
Else
MsgBox "Agent WEB Site Missing From Toolkit Setup", , "Agent WEB Site
Access"
End If
GoTo Exit_1
 
Since the Hyperlink is built one time dynamically, I need to execute what is
built in A17. I tried using the ADD Hyperlink but it does not return an error
or the WEB site. So basically nothing happens. It may have something to do
with the address parameter but I am stuck on how to proceed. This is what I
have now....
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sheets("Toolkit Setup").Select
' If no Agent web site then Alert and Exit
If [A17] <> "" Then
Range("A17").Select
ActiveSheet.Hyperlinks.Add Anchor:=Range("a17"), Address:="",
SubAddress:= _
"'Toolkit Setup'!A17", TextToDisplay:="Agent WEB Address"
Selection.Hyperlinks(1).Follow
GoTo Exit_1
Else
MsgBox "Agent WEB Site Missing From Toolkit Setup", , "Agent WEB Site
Access"
End If
GoTo Exit_1
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Simon Lloyd said:
Marvin;7275492 said:
I built a hyperlink in a cell that works fine when I click on the cell
that
looks like this

=HYPERLINK(CONCATENATE("http://",'Toolkit Setup'!$A$16,"/",'Toolkit
Setup'!$M$12),"Agent "&'Toolkit Setup'!$M$12&" WEB Site")

In a macro I am trying to execute this but it fails with a subscript
out of
range on the Selection.Hyperlinks(1).Follow

' If no Agent web site then Alert and Exit
If [A17] <> "" Then
Range("A17").Select
Selection.Hyperlinks(1).Follow
GoTo Exit_1
Else
MsgBox "Agent WEB Site Missing From Toolkit Setup", , "Agent WEB Site
Access"
End If
GoTo Exit_1It may be because its not actually set up like this


Code:
--------------------
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:= _
"Sheet1!A1", TextToDisplay:="Sheet2!A1"
--------------------
so your not following a cell hyperlink you are accessing a worksheet
formula!

Regards,
SImon
 
Got it working with the following changes. Thanks for your help

A17 has...
="http://"&'Toolkit Setup'!$A$16&"/"&'Toolkit Setup'!$M$12

Macro Looks Like This
On Error GoTo NoInternet
Dim DynamicHyperlink As String
Application.ScreenUpdating = False
Sheets("Toolkit Setup").Select
DynamicHyperlink = Range("A17").Value
' If no Agent web site then Alert and Exit
If [A17] <> "" Then
Range("A17").Select
ActiveSheet.Hyperlinks.Add Anchor:=Range("A17"), Address:=DynamicHyperlink
Selection.Hyperlinks(1).Follow
GoTo Exit_1
Else
MsgBox "Agent WEB Site Missing From Toolkit Setup", , "Agent WEB Site
Access"
End If
GoTo Exit_1
NoInternet:
MsgBox "Internet Could Not Be Reached At This Time " & Err.Description
Exit_1:
 

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


Back
Top