Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Programming
Open most recent file
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Joel, post: 6366898"] Try this code. FILESEARCH doesn't work in excel 2007. This method will work in all excel versions. Yu need to modify FilePath below as required. Sub GetLatestFile() Const FilePath = "Mypath" Set fso = CreateObject _ ("Scripting.FileSystemObject") Set folder = _ fso.GetFolder(FilePath) MyDate = 1 Myfile = "" For Each fl In folder.Files PeriodPos = InStrRev(fl.Name, ".") EXT = Mid(fl.Name, PeriodPos + 1) If UCase(EXT) = "JNK" Then If fl.DateLastModified > MyDate Then Myfile = fl.Path MyDate = fl.DateLastModified End If End If Next fl If Myfile = "" Then MsgBox "There were no files found." Else MsgBox "The newest file is " & Myfile & _ " created " & MyDate Workbooks.Open Myfile End If End Sub [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Programming
Open most recent file
Top