Dear All,
We can use below vba code to open last modified excel file from a folder.
Sub Last_Modified_File()
x = InputBox(“put Folder Path”)
folder_name = x & “\”
flname = Dir(folder_name & “*.xlsx”)
Do While Len(flname) > 0
dttime = FileDateTime(folder_name & flname)
If dttime > qq Then
qq = dttime
End If
flname = Dir()
Loop
folder_name = x & “\”
flname = Dir(folder_name & “*.xlsx”)
Do While Len(flname) > 0
dttime = FileDateTime(folder_name & flname)
If qq = dttime Then
‘qst = folder_name & flname
Workbooks.Open folder_name & flname
Exit Sub
End If
flname = Dir()
Loop
End Sub
No comments:
Post a Comment