Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I perform a file search if I can't distribute Filer.dll?

Tips -N- Tricks

How can I perform a file search if I can't distribute Filer.dll?

by  foxdev  Posted    (Edited  )
Microsoft's licensing for Visual FoxPro states that FILER.DLL cannot be distributed with the VFP runtime. It's a shame, because FILER.DLL provides some file search capabilities that are very easy to use.

But all is not lost. If your clients have any of the Microsoft Office applications (Word or Excel, for example), you can tap into the FileSearch object common to the Microsoft Office applications.

The code below demonstrates how to do this:
************************************

* -- demonstrates a file search using the Microsoft Office FileSearch class

* -- these defines are from the Object Browser in the VB editor
#define msoConditionAnytimeBetween 26

#define msoConnectorAnd 1
#define msoConnectorOr 2

#define msoSortbyFileName 1
#define msoSortbySize 2
#define msoSortbyFileType 3
#define msoSortbyLastModified 4

*****************************

lParameters tcFileSpec, tcStartingDir

if (not type('tcFileSpec') = "C")
return .F.
endif

if (not type('tcStartingDir') = "C")
tcStartingDir = curdir()
endif


* -- IMPORTANT: any of the Microsoft Office applications will suffice, as they
* -- all share the same FileSearch feature; I use Word here
oWord = createobject("Word.Application") && instantiate Word object

With oWord.FileSearch

.NewSearch && clears last results

.LookIn = tcStartingDir
.FileName = tcFileSpec
.SearchSubFolders = .T.

* -- normally, of course, these params would be passed
* -- I just threw this in to show this feature
.PropertyTests.Add("Last Modified", msoConditionAnytimeBetween, ;
"07/01/2000", "07/10/2000", msoConnectorAnd)

lnNumFiles = .Execute(msoSortbyFileName)

* -- the .FoundFiles collection now contains a list of found files
* -- .FoundFiles(1) yields the first file name, etc.

for each cFileName in .FoundFiles

* -- obviously, you'd do something a bit more practical
* -- than just listing them

? cFileName

endfor

EndWith

oWord.Quit
release oWord
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top