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

list files modified after a date/time

Status
Not open for further replies.

ms061780

Technical User
Feb 19, 2007
4
EU
Hi,
can somebody help me how to create a simple and fast running filesearch that returns a list of files last modified after a ceratin date/time?
I found .LastModified function which did not help me because it looks like I have to use this MsoLastModified constants.
Search will not run regulary (sometimes after one week or after two days or after 3 months). Therefore I save the date of last search and want to find later on all files modified after.
THX
Sven
 


Hi,

What application are you using?

What do you mean by, "Search will not run regulary?" Do you have code that you have used? If so, please post.

Please answer ALL these questions.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Hi,
sorry for beeing not precise enough!
I'm still VBA beginner.

I'm using Microsoft EXCEL 2003.
With "Search will not run regulary" I mean that there are no fixed times when the script will run. It will be started manually in variable times.
Thats why the MsoLastModified constants are not suitable for me. I'd like to compare last modified date of found files with the date in Worksheets(1).Cells(1, 1) filled by last execution of the macro (to list only the new files after last run).
Here my filesearch - without any date comparisation becaus I don't know how:
With Application.FileSearch
.LookIn = "D:\project\"
.Filename = "*.pdf"
.SearchSubFolders = True
.Execute
If .Execute > 0 Then
msgbox("There were " & .FoundFiles.Count & _
" file(s) found.")
Worksheets(1).Cells(1, 1).Value = Date()
For i = 1 To .FoundFiles.Count
Worksheets(1).Cells(1+i, 1).Value = .FoundFiles(i)
Next i
Else
MsgBox "There were no files found."
End If

End With
 


Try using the FileSystemObject. The File object has a DateLastModified Property that you can compare to the date in your sheet.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top