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 ha
After searching different websites looking for a solution as to how to separate the full path from the file name once the full one-piece information has been obtained from the Open File Dialog, and seeing how "complex" the solutions given were for an Excel newcomer like me, I wondered if there could be a simpler solution. So I started to work on it on my own and I came to this possibility. (I have no idea if somebody got the same idea before. Being so simple, if somebody has, I excuse myself.)
Dim fPath As String Dim fName As String Dim fdString As String fdString = (the OpenFileDialog.FileName) 'Get just the path by finding the last "\" in the string from the end of it fPath = Left(fdString, InStrRev(fdString, "\")) 'Get just the file name by finding the last "\" in the string from the end of it fName = Mid(fdString, InStrRev(fdString, "\") + 1) 'Just to check the result Msgbox "File path: " & vbLF & fPath & vbLF & vblF & "File name: " & vbLF & fName
AND THAT'S IT!!! Just give it a try, and let me know how it goes...