PDA

View Full Version : Solved: Hyperlink - full address from displayed text



lifeson
06-10-2009, 10:08 AM
Hi all
Thanks to some searching on here I found how to follow a hyperlink when double clicking on a text box on a form :thumb

Private Sub txtLink_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
On Error Resume Next
ActiveWorkbook.FollowHyperlink Address:=fileLink, NewWindow:=True
End Sub

where fileLink is the text from a cell

dim fileLink as string
'..............
fileLink = ws.Cells(rw, "S")

However if when inserting the hyperlink I use alternative text to display rather than displaying the full path I cant get it to work :think:

Question is how do I get fileLink to equal the actual address from the cell and not the text displayed?

mdmackillop
06-10-2009, 11:16 AM
There may be a neater way but try

Private Sub TextBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim filelink As String
Dim sh As Worksheet
Set sh = Sheets(1)
filelink = Cells(9, 5).Address

DoCall sh, filelink
End Sub

Private Sub UserForm_Initialize()
TextBox1.Text = Sheets(1).Cells(9, 5)
End Sub


'In standard module

Sub DoCall(Sht As Worksheet, filelink As String)
Sht.Range(filelink).Hyperlinks(1).Follow
End Sub

lifeson
06-10-2009, 12:22 PM
works for me, thanks mdm!