Group: microsoft.public.word.vba.general
From: "Ker_01"
Date: Monday, March 24, 2008 2:55 PM
Subject: Recursive directory search- syntax question

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


Safety Articles | Usenet Groups | Usenet News | Bluegrass