VBAlearner2010
asked on
Function for Last file saved in VBA
Could anyone please help in replacement code for the below to work in Office 2010
Function LastFileSaved(sFileDir As String, DebutNomFichier As String, Optional sType As String = "*.*") As String
Dim fs
Set fs = Application.FileSearch
With fs
.LookIn = sFileDir
.Filename = DebutNomFichier
If .Execute(SortBy:=msoSortByLastModified, _
SortOrder:=msoSortOrderDescending) > 0 Then
LastFileSaved = .FoundFiles(1)
Else
MsgBox "There were no files found in:" & vbLf & _
sFileDir & vbLf & _
"Type: " & sType
LastFileSaved = vbNullString
End If
End With
End Function
What is DebutNomFichier?
ASKER
Name of the file probably....
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Thank you very much.. It worked.....
ASKER