Hey there,
I'm looking for some code that will open the most recent file in a folder.
Any thoughts?
Here is the file path for the actual file: M:\Locts\0366\0366avail060220.xlsx
Thank you in advance.
Hey there,
I'm looking for some code that will open the most recent file in a folder.
Any thoughts?
Here is the file path for the actual file: M:\Locts\0366\0366avail060220.xlsx
Thank you in advance.
How about...Please Login or Register to view this content.
Close to previous post but as a VBA beginner starter to open the most recent .xlsx file :
PHP Code:
Sub Demo1()
Const P = "M:\Locts\0366\"
Dim F$, D As Date, R As Date, T$
F = Dir(P & "*.xlsx")
While F > ""
D = FileDateTime(P & F): If D > R Then R = D: T = F
F = Dir
Wend
If R Then Workbooks.Open P & T
End Sub
► Do you like it ? ► ► So thanks to click on bottom left star icon « ★ Add Reputation » ! ◄ ◄
Last edited by Marc L; 06-05-2020 at 11:19 AM. Reason: typo …
Thank you for responding, but this only gives me the date and time it was saved.
Works perfectly. Thank you!
Any way to set the "M:\Locts\0366\" as a variable number?
Please Login or Register to view this content.
So it can't be a constant like in my demonstration but a String variable as Dangelor used in his code …
His code only opens a msg box that says when the file was last saved or something
I just pointed out the way dangelor used for the path - a String variable - as you can easily see in his code …
Hey man. I know I'm an idiot you don't gotta rub it in
Thank you.
Working on saving the open workbook as a different name now if the same name exists. Any thoughts, Master Marc?
Last edited by jack.a; 06-05-2020 at 02:37 PM.
You asked for opening the most recent workbook.
So you want to save it with a different name - which I can't guess - but if this different name already exists
then you want to save it with another different name - which I can't guess neither - or ?
Thanks Marc - figured it all out in the end. Here is my code in it's entirety.
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks