Hello Jiptastic,
This should work for you.
' Written: October 20, 2011
' Author: Leith Ross
' Summary: Opens the newest workbook in a folder based on the date it was last modified.
Sub OpenNewestWorkbook()
Dim DateLastModified As Date
Dim Filename As String
Dim Filepath As Variant
Dim Item As Variant
Dim oFolder As Variant
Dim NewestWkb As String
Filepath = "M:\My Folder\\Template REPORTS"
Filepath = IIf(Right(Filepath, 1) <> "\", Filepath & "\", Filepath)
Set oShell = CreateObject("Shell.Application")
Set oFolder = oShell.Namespace(Filepath)
For Each Item In oFolder.Items
If LCase(Item.Name) Like "*.xlsx" Then
If oFolder.GetDetailsOf(Item, 3) > LastDateModified Then
NewestWkb = Item.Name
LastModified = oFolder.GetDetailsOf(Item, 3) ' 3 = Modified, 4 = Created, 5 = Accessed
End If
End If
Next Item
If NewestCSV <> "" Then Workbooks.Open Filepath & NewestWkb
End Sub
Bookmarks