Group: microsoft.public.word.vba.general
From: "Karl E. Peterson"
Date: Monday, March 24, 2008 3:03 PM
Subject: Re: Recursive directory search- syntax question

I have no idea why the object model may be breaking down here. But if you'd like to
do a "pure VB(A)" recursive search, see http://vb.mvps.org/samples/DirDrill for a
drop-in ready class module. Black boxes are *always* better when they're
transparent! :-)
--
.NET: It's About Trust!
http://vfred.mvps.org



Ker_01 wrote:
> I've tried to adapt some old code to recursively check for word files in the
> target directory so I can open each one and inspect the contents with VBA
> (per my previous post). Unfortunately, the following code appears to hang on
> the .execute command. Right now, the test directory has about 50 files and
> no subdirectories. CPU and network access are nominal, so AFAIK this doesn't
> appear to be a situation where it is just taking forever to execute
> (although I welcome suggestions on how to know for sure).
>
> Is my syntax wrong, or can anyone suggest alternative troubleshooting?
>
> Thanks,
> Keith
>
>
> Sub FindAllTxtFiles() 'finds all .doc files in the target directory
>
> DirPath = "\\networkdrive\test" 'also tried with a trailing "\"
> just in case it needed one
>
> With Application.FileSearch
> .NewSearch
> .LookIn = DirPath 'selected directory
> .SearchSubFolders = True
> .FileName = "*.doc"
> If .Execute > 0 Then '*** stops here ***
> For i = 1 To .FoundFiles.Count
> 'Do my file processing here
> MsgBox FileName
> Next i
> End If
> End With
>
> End Sub