Hello,
I have a userform that populates an excel worksheet.
The user fills in the userform, presses the "submit" button and it sends all the information to a spreadsheet.
I have now added an option to reference appropriate files (pictures, documents etc.). On the same userform, the user can press a button which opens a file browser window. The user finds their file and presses "OK" and the file path is displayed in a text box that I've placed on the userform.
When the "submit" button on the userform is pressed, the spreadsheet is populated including the file path bit.
The above works well. In the database I can see the filepath as text but what I would like to do is have it as a hyperlink to the file itself.
Therefore, rather than the userform populating the filepath as a piece of text, is it possible to populate it as a link to the document it's referring to?
This is what I have done to get the filepath into the userform. The command button is called "Find_File" and the associated text box is called "File_Ref":
Private Sub Find_File_Click()
Dim Filename As Variant
Filename = Application.GetOpenFilename("All Files (*.*),*.*")
If Filename = False Then Exit Sub
File_Ref.Value = Filename
End Sub
To send the userform information to a worksheet database I have used:
Private Sub Submit_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Database")
iRow = ws.Cells.Find(what:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
ws.Cells(iRow, 2).Value = Me.Textbox1.Value
ws.Cells(iRow, 3).Value = Me.Textbox2.Value
ws.Cells(iRow, 4).Value = Me.File_Ref.Value
End Sub
Is there a way to get the last line like?:
ws.Cells(iRow, 4).Value = Me.File_Ref.Hyperlink
Bookmarks