Hi everybody, I built and manage a compliance database for my company. Instead of actually attaching PDFs to the records, to keep size down -- I've added a hyperlink text box to hold a hyperlink to the file. I have a command button (cmdFileDialog) which brings a file selector up and lets the user navigate to and select a file. The file path is populated into the text box txtFileHyperlink.
The issue is, the path is a mapped network path (for example R:/path/path/file.pdf). Users have the drive mapped differently, so I'm trying to have the file selector extract the UNC path instead -- or may convert the path to UNC.
Does anybody have any experience or guidance on how I might modify the code below to achieve this?
Any input is greatly appreciated.
The issue is, the path is a mapped network path (for example R:/path/path/file.pdf). Users have the drive mapped differently, so I'm trying to have the file selector extract the UNC path instead -- or may convert the path to UNC.
Does anybody have any experience or guidance on how I might modify the code below to achieve this?
Any input is greatly appreciated.
Code:
Private Sub cmdFileDialog_Click()
Dim f As Object
Set f = Application.FileDialog(3)
f.AllowMultiSelect = False
If f.Show Then
For i = 1 To f.SelectedItems.Count
sFile = Filename(f.SelectedItems(i), sPath)
txtFileHyperlink = sPath & sFile
Next
End If
End Sub
Public Function Filename(ByVal strPath As String, sPath) As String
sPath = Left(strPath, InStrRev(strPath, "\"))
Filename = Mid(strPath, InStrRev(strPath, "\") + 1)
End Function