Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How about this:
Private Sub CommandButton1_Click() Debug.Print GetOldestModifiedFile("C:") End Sub Public Function GetOldestModifiedFile(argFolderToSearch As String, _ Optional argPattern As String = "*.xls") _ As String Dim FileName As String Dim FileDate As Date Dim OldestDate As Date Dim OldestFile As String If Right(argFolderToSearch, 1) < "\" Then argFolderToSearch = argFolderToSearch & "\" OldestFile = "" OldestDate = 50000 FileName = Dir(argFolderToSearch & argPattern, vbNormal) Do Until FileName = "" FileDate = FileDateTime(argFolderToSearch & FileName) If FileDate < OldestDate Then OldestDate = FileDate OldestFile = FileName End If FileName = Dir() Loop GetOldestModifiedFile = OldestFile End Function NickHK "farful" wrote in message ... Hi, I was wondering if someone could show me how, give a directory (no need for sub directories or hidden files or system files, etc) to open the last modified excel file given a partial string (the beginning part of the filename) using VBA, preferably using the "Dir" function. -- farful ------------------------------------------------------------------------ farful's Profile: http://www.excelforum.com/member.php...o&userid=36172 View this thread: http://www.excelforum.com/showthread...hreadid=563360 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Finding a word in CSV files | Excel Discussion (Misc queries) | |||
finding excel files | New Users to Excel | |||
Finding Excel files | Excel Discussion (Misc queries) | |||
Finding files in a directory | Excel Programming | |||
filesearch not finding files | Excel Programming |