Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Recursive directory search- syntax question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ker_01 - 24 Mar 2008 20:55 GMT
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
Karl E. Peterson - 24 Mar 2008 21:03 GMT
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! :-)
Signature

.NET: It's About Trust!
http://vfred.mvps.org

> 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
[quoted text clipped - 28 lines]
>
> End Sub
Doug Robbins - Word MVP - 25 Mar 2008 09:46 GMT
I had intended the counters only to be used for the tables and the rows
within them.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> 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
[quoted text clipped - 28 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.