PC Review


Reply
Thread Tools Rate Thread

Application.FileSearch vs. Dir

 
 
Tim Peterson
Guest
Posts: n/a
 
      30th Jun 2004
Is there any way to get FileSearch to function on XP or is
there any way to get Dir to search sub folders?

I recently developed and tested a application using Access
97 / Win98. The application crashes in WinXP when it
executes FileSearch. Knowlege Base Article 259738 says
that FileSearch may fail on a Windows 2000-based computer
and suggests using Dir (Does this article apply to XP?).
I posted an earlier thread in various groups and the
replies generally suggested that I check references on
both workstations. I did this, and the references checked
in checkboxes are the same on both. I rewrote the
procedure using Dir instead of FileSearch, and it works
fine except that files in subfolders are not returned as
with FileSearch.SearchSubFolders = True.

Is there any way to get FileSearch to function on XP or is
there any way to get Dir to search sub folders?

Tim Peterson
 
Reply With Quote
 
 
 
 
Albert D. Kallal
Guest
Posts: n/a
 
      30th Jun 2004
You can easily modify the following example:

just change:

For i = 1 To dlist.Count
Debug.Print dlist(i)
Next i

to:

if dlist(i) = your file name then
got one!


Anyway..give the following code a try..it is short, and it runs very fast...

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
(E-Mail Removed)
http://www.attcanada.net/~kallal.msn

Sub dirTest()

Dim dlist As New Collection
Dim startDir As String
Dim i As Integer

startDir = "C:\access\"
Call FillDir(startDir, dlist)

MsgBox "there are " & dlist.Count & " in the dir"

' lets printout the stuff into debug window for a test

For i = 1 To dlist.Count
Debug.Print dlist(i)
Next i

End Sub


Sub FillDir(startDir As String, dlist As Collection)

' build up a list of files, and then
' add add to this list, any additinal
' folders

Dim strTemp As String
Dim colFolders As New Collection
Dim vFolderName As Variant

strTemp = Dir(startDir)

Do While strTemp <> ""
dlist.Add startDir & strTemp
strTemp = Dir
Loop

' now build a list of additional folders
strTemp = Dir(startDir & "*.", vbDirectory)

Do While strTemp <> ""
If (strTemp <> ".") And (strTemp <> "..") Then
colFolders.Add strTemp
End If
strTemp = Dir
Loop

' now process each folder (recursion)
For Each vFolderName In colFolders
Call FillDir(startDir & vFolderName & "\", dlist)
Next vFolderName

End Sub


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA - Application.Filesearch Nelson79 Microsoft Excel Discussion 0 12th Jun 2011 10:58 AM
Application.FileSearch Cleberton(Brazilian) Microsoft Excel Misc 2 26th Oct 2009 01:21 PM
application.filesearch dstiefe Microsoft Excel Programming 3 13th Aug 2009 10:30 PM
Application.Filesearch EA Microsoft Excel Programming 3 17th Aug 2006 10:07 AM
Application.FileSearch Bernie Microsoft Access Form Coding 1 21st Sep 2004 01:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:33 PM.