Look up file by date/time stamp.
How would I open a file by the date and or time stamp on the file?
Occassionally I receive a downloaded file that is in a text format These files are received daily 2x a day. The filename is typically. GEN-filename-month-day-year-random number.txt I believe the easiest technique is to open a file with these parameters is to open with GEN-filename-* {asterix being a wild card} and then look for the time date stamp to pull the newest file. Thanks |
Look up file by date/time stamp.
Give this code snippet a try (just incorporate it into your current code...
Dim Path As String Dim Filename As String Dim LatestFileName As String Dim LatestFileDate As Date ' Note: The path must always end with a backslash Path = "c:\temp\" Filename = Dir$(Path & "GEN-filename-*.txt") Do While Len(Filename) 0 If FileDateTime(Path & Filename) LatestFileDate Then LatestFileName = Path & Filename LatestFileDate = FileDateTime(Path & Filename) End If Filename = Dir$ Loop ' ' LatestFileName contains the path/filename of the most ' recent file, so Open it and do what you need to with it ' Rick "Rpettis31" wrote in message ... How would I open a file by the date and or time stamp on the file? Occassionally I receive a downloaded file that is in a text format These files are received daily 2x a day. The filename is typically. GEN-filename-month-day-year-random number.txt I believe the easiest technique is to open a file with these parameters is to open with GEN-filename-* {asterix being a wild card} and then look for the time date stamp to pull the newest file. Thanks |
All times are GMT +1. The time now is 01:08 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com