Get date from External file...

themanof83

Registered User.
Local time
Today, 22:38
Joined
May 1, 2008
Messages
73
Hi guys,

I am fairly new to coding so please tell me if this is fairly simple.
I have a date field in a form which is basically telling me the date stamp of a file. At present I am entering this date manually which seems long winded. Therefore, I would like to have this field automated and can see two ways, but am not sure how to go about it:

1. Take the date from the files windows explorer date stamp.

2. Extract the date from a common line in the file.

Thanks in advance,

Ashley
 
Yes it's pretty simple stuff. Here's an example

Code:
Sub bleh()

    Dim fs, f, s, filespec
    filespec = "c:\testfile.txt"
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFile(filespec)
    Debug.Print f.DateCreated
    Debug.Print f.DateLastAccessed
    Debug.Print f.DateLastModified

End Sub
 
Re:

Looks good Chergh, only how would I get that to my field in the form???

Cheers.
 
Code:
    Dim fs, f, s, filespec
    filespec = "c:\testfile.txt"
    Set fs = CreateObject("Scripting.FileSystemObject")
    Set f = fs.GetFile(filespec)
    me!field_name1 = f.DateCreated
    me!field_name2 = f.DateLastAccessed
    me!field_name3 f.DateLastModified
 
Sorry that was me being lazy, I should have figured that out myself, thanks.
Is there also a way to limit the DateLastModified to only show the date and not the date and time??
Thanks again.
 
Yeah you can use the format function

Code:
me!field_name3 = Format(f.DateLastModified, "dd/mm/yyyy")
 
Thanks for all your help Chergh.
Do you also know how to combat this problem the other way (point 2.)?
For example there is a text file that exists in that directory which on the 3rd line says:

Date: 3-Mar-08

How can I grab this?
Regards,

Ashley
 

Users who are viewing this thread

Back
Top Bottom