Charlotte Foust
cfoust at infostatsystems.com
Sun Apr 27 15:56:40 CDT 2003
I've used it because it is flexible and easy. The alternatives are
what, Dir? Not much of an alternative. Or are you asking about using
it instead of the FileSystemObject? One thing I like about it is that
it returns a FoundFiles collection that you can iterate through.
Another is that you can specify multiple specifications as a semicolon
delimited list in the FileName argument, which makes it very flexible.
Here's something I built to return a list of files using FileSearch.
The idea was to present the user with a dropdown list of files that
matched any passed specifiications without using the common dialog.
Public Function BuildFileList(ByVal strPath As String, _
Optional strLike As String) As String
'Created by Charlotte Foust 4/18/2000
Dim strList As String
Dim intLoop As Integer
'If no filename comparison
'was passed, look for all.
If strLike = "" Then
strLike = "*.*"
End If
With Application.FileSearch
.NewSearch
.LookIn = strPath
.FileType = msoFileTypeAllFiles
.FileName = strLike
If .Execute() > 0 Then
For intLoop = 1 To .FoundFiles.Count
'concatenate the filename to the list
strList = strList & ExtractFileName(.FoundFiles(intLoop)) & ";"
Next intLoop
End If
End With
If Len(strList) > 0 Then
'If a list was created, remove
'the last delimiter.
strList = Left(strList, Len(strList) - 1)
End If
BuildFileList = strList
End Function
Charlotte Foust
-----Original Message-----
From: Susan Harkins [mailto:harkins at iglou.com]
Sent: Saturday, April 26, 2003 3:48 PM
To: AccessD at databaseadvisors.com
Subject: [AccessD] FileSearch object
I'm trying to come up with a good reason for bothering to use the
FileSearch object -- so far the only thing I've come up with is wanting
to control the search process by being inclusive or exclusive with
search parameters. Anyone ever used it and if so, why?
Susan H.
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com