I found a code snippet (I think on here) which brings up the standard "Open File" Dialog, so that the user can find a file.
It then returns the file path to the active cell as a link.
The only problem is that if the file is on a network drive (Which it will almost certainly always be), it returns the path as mapped on the user's computer.
So, say the file is on \\fps01\shares\revenue and the filename is "Sample.doc", if the user has that drive mapped to "Z", it returns the filename:
Z:\Sample.doc
When I want it to return:
\\fps01\shares\revenue\Sample.doc
Is this possible?
Chris
It then returns the file path to the active cell as a link.
The only problem is that if the file is on a network drive (Which it will almost certainly always be), it returns the path as mapped on the user's computer.
So, say the file is on \\fps01\shares\revenue and the filename is "Sample.doc", if the user has that drive mapped to "Z", it returns the filename:
Z:\Sample.doc
When I want it to return:
\\fps01\shares\revenue\Sample.doc
Is this possible?
Chris
Code:
Sub Button2_Click()
Dim Filter As String, Title As String
Dim FilterIndex As Integer
Dim Filename As Variant
Filter = "View All Files (*.*),*.*," & _
"Microsoft Excel Spreadsheet (*.xls),*.xls," & _
"Microsoft Word Document (*.doc),*.doc,"
FilterIndex = 3
Title = "Select a File to Open"
With Application
Filename = .GetOpenFilename(Filter, FilterIndex, Title)
End With
If Filename = False Then
Exit Sub
Else
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=Filename, SubAddress:= _
"", TextToDisplay:=Filename
End If
End Sub