Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determining create date of txt file before loading 2

Status
Not open for further replies.

dbero

Technical User
Mar 31, 2005
109
US
I am importing a txt file from a vbform. However, sometimes the file creation is delayed so I want to check the DOS modified/created date prior to performing the append query. Can you please provide some insight as to how to determine a txt file's modified/created date from vba?

Thanks,

 
Hi
I found this sample in an old MSDN library:
Code:
Dim MyStamp
' Assume TESTFILE was last modified on February 12, 1993 at 4:35:47 PM.
' Assume English/U.S. locale settings.
MyStamp = FileDateTime("TESTFILE")   ' Returns "2/12/93 4:35:47 PM".


 
dbero,
The 3 file dates (Accessed/Created/Modified) are available in the File object in the Scripting Filesystemobject.

Here's a snippet:
Code:
Private Sub FileDate()
Dim acDate As Date
Dim crdate As Date
Dim modate As Date
Dim fso As New FileSystemObject
Dim fil As File

Set fil = fso.GetFile("C:\ASCFILE.TXT")

acDate = fil.DateLastAccessed
crdate = fil.DateCreated
modate = fil.DateLastModified
End Sub

You'll need a reference in your project to the Scripting Runtime.

Tranman


"Adam was not alone in the Garden of Eden, however,...much is due to Eve, the first woman, and Satan, the first consultant." Mark Twain
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top