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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel 2010 Add Hyperlink to Sheet from Userform "File Open" Process

Status
Not open for further replies.

PWD

Technical User
Jul 12, 2002
823
GB
Good afternoon. My user has asked me to amend a workbook and include the selection of a hyperlink to an 'evidence' (not police related!!) file. I think I've got as far as being able to populate the relevant cell from this input code but (ignoring any issue surrounding drive letter mapping) I'm unsure as how to make sure the cell turns into a hyperlink.

Code:
Private Sub EvidenceLinkButton_Click()

Dim strFileToLink As String

strFileToLink = Application.GetOpenFilename _
(Title:="Please select an Evidence file to link to")

    'Checking if file is selected
    If strFileToLink = "" Then
        
        'Displaying a message if file not choosedn in the above step
        MsgBox "No file selected.", vbExclamation, "Sorry!"
        
        'And exiting from the procedure
        Exit Sub
    Else
    
    UserFormAddNewEvidenceB.EvidenceLinkTextBox.Value = strFileToLink
    ''    Workbooks.Open Filename:=strFileToLink
    End If

End Sub

................
                iRow.Range.Cells(1, 2).Value = EvidenceLinkTextBox.Value ''Evidence Link
...............

I've tried:

Code:
                Hyperlinks.Add Anchor:=iRow.Range.Cells(1, 2) = EvidenceLinkTextBox.Value ''Evidence Link

But it's treating "Hyperlinks" as an undeclared variable. Am I close?



Many thanks,
D€$
 
Got it:

Code:
                wrksht.Hyperlinks.Add Anchor:=iRow.Range.Cells(1, 2), Address:=EvidenceLinkTextBox.Value  ''Evidence Link

Many thanks,
D€$
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top