Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparing 2 files on date/time stamp, and based time difference do a subroutine [email protected] Excel Programming 1 September 28th 07 03:53 AM
Save File with Date and Time Stamp Andibevan[_3_] Excel Programming 9 May 4th 06 01:17 AM
Save file with time date stamp oberon.black[_91_] Excel Programming 1 September 22nd 05 01:13 AM
Date/time Stamp? Bowes813[_3_] Excel Programming 7 June 3rd 05 08:10 AM
Getting a File Date & Time stamp James Excel Programming 5 February 8th 05 07:15 PM


All times are GMT +1. The time now is 07:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"