Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Comparing 2 files on date/time stamp, and based time difference do a subroutine | Excel Programming | |||
Save File with Date and Time Stamp | Excel Programming | |||
Save file with time date stamp | Excel Programming | |||
Date/time Stamp? | Excel Programming | |||
Getting a File Date & Time stamp | Excel Programming |