Filesystem object - finding folder?

kirkm

Registered User.
Local time
Today, 17:05
Joined
Oct 30, 2008
Messages
1,257
Is it possible to get a foldername where the name contains, for example, *xyz*
and the parent folder is known ?

If the folder exists it will be a subfolder off the parent folder, not a subfolder off a subfolder.

I've been trying to do this with the folder system object but end up looping through several hundred names and feel there may be a better way ?
 
You do not need the FileSystemObject for this task; you can use the Dir command, like the following example:
Code:
[COLOR="Navy"]Dim[/COLOR] vFolderName [COLOR="Navy"]As Variant[/COLOR]

vFolderName = Dir("C:\MyParentFolder\*xyz*", vbDirectory)

[COLOR="navy"]Do While[/COLOR] vFolderName > ""
    [COLOR="navy"]Debug[/COLOR].[COLOR="navy"]Print[/COLOR] vFolderName
    vFolderName = Dir
[COLOR="navy"]Loop[/COLOR]
 

Users who are viewing this thread

Back
Top Bottom