Reputation: 113
I have a folder that I'm not sure of its full name - I have only part of the folder name. So I am trying to find a vba code that will be given a partial folder path, and will return the full path.
For example: The full path is: "C:\Documents\Folder1ABC", but I only know that the path is something like this: "C:\Documents\Folder1*".
Is there a VBA code that can solve this?
Upvotes: 1
Views: 7467
Reputation: 928
You can use the Dir
function...
Sub testDir()
Debug.Print Dir("c:\documents\Folder1*", vbDirectory)
End Sub
We use the vbDirectory
attribute to specify that only a directory will be returned. More details at MSDN Dir function page
Upvotes: 6