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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fast VBA code that searches for files created after given date/time

Status
Not open for further replies.

cravincreeks

Technical User
Jun 18, 2004
85
US
Hello all. I'm seeking a fast routine that will list all files (by file name) in a given directory that were created after a particular date and time.

This will be run in ESRI's ArcGIS and that software has its own 'Application' object. Consequently, it could get tricky if I attempt to use the MS Office FileSearch object. For example, if I try to write

Code:
Dim fs as Object
Set fs = Application.FileSearch
then I get an error saying that the object does not support the method or property.

The number of files in the directory that I want to search will soon be huge (thousands of files), so I'm hoping that I can find some code that is very fast.

Thanks!
 
I'm probably being stupid here but could you do a DOS command, something like:- dir/tc/od | find /V "<DIR>" | find /V "Directory of" | find ":" > somefilename (this can be done in vba via the shell command). This will give you a list of date ordered files in somefilename. Then you do a quick parse of somefilename in VBA using FSO or whatever to get the ones you wanted. You might have to tweak the find commands to cope with other situations but if you get it right it could be pretty quick.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top