Text file import to table with File Date (1 Viewer)

daievans

Registered User.
Local time
Today, 10:21
Joined
Apr 3, 2013
Messages
75
I'm able to import the contents of the text file into a table, thanks to the help of folks in this forum.

What's the best way of tying the data from the text file to the filename and its date? As the files are relatively small in size and they later get scripted into another system, I think I'm limited to a flat file solution, not a relational database.

I'd like every text record to also have the file date included with it .... does that make sense to anyone?

Thanks!
 

Estuardo

Registered User.
Local time
Today, 18:21
Joined
May 27, 2003
Messages
134
G'd Afternoon daievans,
to get the file properties you need a refeence to the File Scripint Object Library (FSO) then you can do something like this
Code:
Private Function FileDate(strFilePath as String) As String
    On Error GoTo ErrHandler
    Dim fso As FileSystemObject
    Dim oFile As File

    Set fso = CreateObject("Scripting.FileSystemObject")
    Set oFile = fso.GetFile(strFilePath)

   
   
    FileDate = oFile.DateCreated
    [COLOR="SeaGreen"]'FileDate= oFile.DateLastAccessed
    'FileDate = oFile.DateLastModified[/COLOR]
     Set oFile =Nothing
     Set fso =Nothing
If that makes sense... that's depends on your needs and further use of that info.

G'd luck
 

daievans

Registered User.
Local time
Today, 10:21
Joined
Apr 3, 2013
Messages
75
G'd Afternoon daievans,
to get the file properties you need a refeence to the File Scripint Object Library (FSO) then you can do something like this
Code:
Private Function FileDate(strFilePath as String) As String
    On Error GoTo ErrHandler
    Dim fso As FileSystemObject
    Dim oFile As File
 
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set oFile = fso.GetFile(strFilePath)
 
 
 
    FileDate = oFile.DateCreated
    [COLOR=seagreen]'FileDate= oFile.DateLastAccessed[/COLOR]
[COLOR=seagreen]   'FileDate = oFile.DateLastModified[/COLOR]
     Set oFile =Nothing
     Set fso =Nothing
If that makes sense... that's depends on your needs and further use of that info.

G'd luck


Thank you Estuardo - that was one of the solutions I pondered. I ended up using FileDateTime and FileLen - both VBA functions.

And they worked!

Thanks again and welcome to the Forum!
 

Users who are viewing this thread

Top Bottom