Link to home
Create AccountLog in
Avatar of VBAlearner2010
VBAlearner2010Flag for France

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

Open in new window

Avatar of VBAlearner2010
VBAlearner2010
Flag of France image

ASKER

Kindly let me know asap...  I will have to deliver this app today.
Avatar of mbizup
What is DebutNomFichier?
Name of the file probably....
ASKER CERTIFIED SOLUTION
Avatar of mbizup
mbizup
Flag of Kazakhstan image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Thank you very much.. It worked.....