I need the path name and file name of the file that is opened with File Dialog. I want to show this information with a hyperlink in my worksheet.
With this code I have the file path:
Sub GetFilePath()
Set myFile = Application.FileDialog(msoFileDialogOpen)
With myFile
.Title = "Choose File"
.AllowMultiSelect = False
If .Show <> -1 Then
Exit Sub
End If
FileSelected = .SelectedItems(1)
End With
ActiveSheet.Range("A1") = FileSelected
End Sub
I’m still looking for a way to get the filename.
Try this