Function MostRecent(strFolderPath, strFileExtension) 'Returns the full path of the most recent file Dim fs, fol, fils, fil, strMostRecent Set fs = CreateObject("Scripting.FileSystemObject") Set fol = fs.GetFolder(strFolderPath) Set fils = fol.Files strMostRecent = "" For Each fil In fils If Lcase(fs.GetExtensionName(fil.Name)) = LCase(strFileExtension) Then If strMostRecent = "" Then strMostRecent = fil.Path End If If fil.DateLastModified > fs.GetFile(strMostRecent).DateLastModified Then strMostRecent = fil.Path End If End If Next MostRecent = strMostRecent End Function