PDA

View Full Version : Return List of Folders Containing a Specific Word



rrenis
05-02-2007, 07:39 AM
Hi - does anyone know if it's possible to search through all of the sub-folders in a directory and return a list of folders containing a specific word in a list box within a userform?

I've had a look on google today but so far come up empty handed :(

Cheers,
rrenis

Simon Lloyd
05-02-2007, 11:22 AM
Remeber that workbook i attached for you in the other thread? well it has this section of code:

Sub TestTheFunction_EntireCdrive()
Dim t2
t2 = InputBox("Enter Document Extention Name " & Chr(13) & "Like: .Xls, .Doc, .Txt or .PPT ", "File Finder")
CustomFindFile ("*" & t2) 'If you only ever want to search for excel files use ("*.xls") and loose the line above
End Sub
just change the section in CustomFindFile to ("Example " & "*" & t2)in this change the code will look for any specified file type with the word "Example" first then a wildcard word denoted by "*" and then the file extension....NOTE: where i typed Example i left a space at the end "Example " my search then came up with "Example Book.xls", "Example VBAX.xls "...etc

Regards,
Simon

P.S you can make those hyperlinks available in a combobox!

rrenis
05-03-2007, 12:45 AM
Hi Simon - thanks for the reply! :hi:

The note about the combobox is very interesting - I'll have a mess with that thanks!! :bow:

Unfortunately I don't think I explained things very well in my original post. I'm not looking to return files with a specific word in them but just the Folders.

So if I searched for test in the following list of directories only those in red will be returned.

C:\Projects\One project\
C:\Projects\Another project\
C:\Projects\Yet andother test project\
C:\Projects\And yet another project\
C:\Projects\And yet andother test project\

Cheers,
rrenis.

Simon Lloyd
05-03-2007, 04:23 AM
rrenis, i came across this program which does exactly what you need matbe you could modify the code to suit you....great little program!

Regards,
Simon

rrenis
05-03-2007, 05:09 AM
Hi Simon - thanks for sharing this. Looks promising!! I'll have a look through the code and see if I can modify it to search for text in the folders.

Once again, thanks for giving up your time to help me out!! :thumb

Cheers,
rrenis