Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Followhyperlink using an address listed in a cell

Status
Not open for further replies.

bdmangum

Technical User
Dec 6, 2006
171
US
I'm attempting to use the ActiveWorkbook.FollowHyperlink command to open a browser using an address located in a cell. I need to do it this way due to having a large list of objects and the window has to open a different webpage based upon the object selected. Basically I need to be able to set the address using a string variable, instead of a string address.

Here is my code
Code:
Private Sub Label3_Click()
Dim linker As String

linker = Worksheets("Object List").Cells(Counter, SubCounter + 2).Value

'Thus linker now is equal to "[URL unfurl="true"]www.microsoft.com"[/URL] simply set as a test

ActiveWorkbook.FollowHyperlink Address:=linker, _
    NewWindow:=True

End Sub

I receive a run-time error '-2147221014(800401ea)': Cannot open specified file.
 
ActiveWorkbook.FollowHyperlink Address:=" & linker, NewWindow:=True

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I figured out the problem. I was inserting the address using only " when the string requires it start with "
Code:
Private Sub Label3_Click()
Dim linker As String

linker = Worksheets("Object List").Cells(Counter, SubCounter + 2).Value

'Thus linker now is equal to "[b]http://[/b][URL unfurl="true"]www.microsoft.com"[/URL] simply set as a test

ActiveWorkbook.FollowHyperlink Address:=linker, _
    NewWindow:=True

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top