VBA Hyperlink

dimitri

Board Regular
Joined
Nov 8, 2010
Messages
78
Hi,
I'm trying to access a hyperlink in VBA. The full link is held in a cell in sheet 1. I'm having trouble getting the last line of my code to work. any help would be appreciated. thanks.

Code:
Sub OpenReport()
Dim Link As String
Link = Range("Full.Link").Value
Worksheet(1).FollowHyperlink Link
End Sub
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi Dimitri,

It's hard to tell if you are trying to reference a named range, an existing hyperlink or a cell value that could be used as a hyperlink address.

Here are a couple of options that might in either of those situations.

If you have a text value that represents and address in a cell or named cell want to follow that value...
Code:
ActiveWorkbook.FollowHyperlink Address:=Sheets("Sheet1").Range("D2").Value
 
'or
 
ActiveWorkbook.FollowHyperlink _
   Address:=Sheets("Sheet1").Range("MyNamedRange").Value

If you have an existing Hyperlink in a single cell and want to follow that Hyperlink...
Code:
Range("D2").Hyperlinks(1).Follow

Just let me know if I misunderstood.
 
Upvote 0
JS411,
Sorry for the opacity, I was referencing the file path in the form of a text string which was held in a cell. I slightly modifies the second option you suggested and it works perfectly. Thanks for the help!
 
Upvote 0

Forum statistics

Threads
1,224,518
Messages
6,179,258
Members
452,901
Latest member
LisaGo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top