I have a list of a few hundred text file paths varying in number of folders.
eg C:/user/folder/subfolder/filename.docx
I need to split these into the file name and folders. I used to do this by using excel functions "FIND", "LEN", "RIGHT" etc. but this only worked if all paths have the same number of folders which is currently not the case.
How might I complete this in VBA? My VBA knowledge is minimal but with this being such a common task, there should be a script out there somewhere that completes this?
I have searched the web, but it is hard to find a script that completes this.
Any help whatsoever would be really appreciated.
Thanks!
If you wanted a VBA approach, something like the following would work:
Dim fso As FileSystemObject
Dim path As String
Dim folder As String
Dim file As String
path = "C:/user/folder/subfolder/filename.docx"
Set fso = New FileSystemObject
folder = fso.GetParentFolderName(path)
file = fso.GetFileName(path)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.