How to Open Newest File in a Folder in Microsoft Excel
In case you want a VBA code which will allow you to open the recently saved file in the folder with just a click on macro button.
Question): I have a team of 10 people & I am urgently looking for a macro that will help me in opening the latest file saved by team member so that I do not have to go the path wherein the file is saved.
We need to follow the below steps:
Dim MyPath As String
Dim MyFile As String
Dim LatestFile As String
Dim LatestDate As Date
Dim LMD As Date
MyPath = "C:\Users\Documents\"
If Right(MyPath, 1) <> "\" Then MyPath = MyPath & "\"
MyFile = Dir(MyPath & "*.xls", vbNormal)
If Len(MyFile) = 0 Then
MsgBox "No files were found...", vbExclamation
Do While Len(MyFile) > 0
LMD = FileDateTime(MyPath & MyFile)
If LMD > LatestDate Then
LatestFile = MyFile
LatestDate = LMD
MyFile = Dir
Workbooks.Open MyPath & LatestFile
In this way, using macro code, we will be able to open the latest file saved by the team member.
The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.