This is how to return the most recent file in a folder
Dim fso, path, file, recentDate, recentFile
Set fso = CreateObject(“Scripting.FileSystemObject”)
Set recentFile = Nothing
For Each file in fso.GetFolder(“C:\scripts”).Files
If (recentFile is Nothing) Then
Set recentFile = file
ElseIf (file.DateLastModified > recentFile.DateLastModified) Then
Set recentFile = file
End If
Next
and then I wanted to read that file
Set objFileToRead = CreateObject(“Scripting.FileSystemObject”).OpenTextFile(“C:\scripts\” & recentFile.Name,1)
strFileText = objFileToRead.ReadAll()
objFileToRead.Close
Set objFileToRead = Nothing