12-29-2009, 03:40 AM
Then just add the code for it
This code may not be perfect, but by storing and comparing the file created dates you should find the last file created then store the filename. Might have to cast the date variables to get them to compare as dates correctly.
[/code]
Code:
Set objFileSysOb = CreateObject("Scripting.FileSystemObject")
Set colFolderName = objFileSysOb.GetFolder("Give your Parent Folder path here")
Set vFiles =colFolderName.Files
dim f, datecreated, lastfilename
For each i in vFiles
FileName=d(ubound(d))
f = objFileSysOb.GetFile(FileName)
if datecreated = "" then
datecreated = f.DateCreated
lastfilename = FileName
else
'check lastdate to current file
if datecreated < f.DateCreated then
datecreated = f.DateCreated
lastfilename = FileName
end if
end if
Next
msgbox "Last file created was " & lastfilename
This code may not be perfect, but by storing and comparing the file created dates you should find the last file created then store the filename. Might have to cast the date variables to get them to compare as dates correctly.
[/code]