Hi all,
Since xls2007 doesn't include application.filesearch it seems we're going back to using Dir (path, filters) to work with files in folders. I can figure out how to use Dir instead of filesearch below, but I'm stuck on how to make sure I get the most recent version of the file (it's saved daily and called "Baskets 2011-mm-dd.xls").
Any ideas how to sort by date if we can't use filesearch? Many thanks to all!
Code:
With Application.FileSearch
.NewSearch
.LookIn = strFolderName
.filename = "Baskets*.xls"
' the filenames include the date such as "Baskets 2011-02-23.xls"
.Execute SortBy:=msoSortBydate
.LookIn = strFolderName
.filename = "Baskets*.xls"
If .Execute(msoSortByLastModified, msoSortOrderDescending) > 0 Then
strFileName = .FoundFiles(1)
Application.Workbooks.Open strFileName
End If
End With