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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Post revisited - date last modified

Status
Not open for further replies.

mastro78

Programmer
Apr 10, 2007
70
US
I'm not sure if I'm clear on this, so let me re-phrase.

tblLocation, tblSpreadsheets
tblLocation - full location of excel spreadsheets (fields are Location1, Location2)
tblSpreadsheets - name of excel spreadsheets (fields are Spreadsheet, DateMod)

I currently have code where the user selects the location of where the excel spreadsheets are going to be saved. Then when they click save, a function is called that immediately looks into the directory and stores the file names of those excel spreadsheets into a table (tblSpreadsheets). Then on a switchboard OnOpen event it then pulls in all the data from those spreadsheets by location and file name. What i would like is a way to also store is the date modified of those spreadsheets?

Please advise, and thank you for your help on this.
 
Have a look at the FileDateTime function.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The following function will give you the Date Last Modified of a file:
Code:
Public Function fDateLastModified(ByVal sFilePath As String) As Date
On Error Resume Next

    Dim fso As Object

    Set fso = CreateObject("Scripting.FileSystemObject")
    fDateLastModified = fso.GetFile(sFilePath).DateLastModified
    Set fso = Nothing

End Function
Example:
?fDateLastModified("C:\My Folder\MyFile.xls")
 
Why reinvent the wheel ?
Example:
? FileDateTime("C:\My Folder\MyFile.xls")
 
Whenever I insert the FileDateTime(myname) into my code i get a runtime 53 error. I'm assuming i don't need the previous code above to make your (PHV) example work?
 
Code:
?FileDateTime("C:\myfile.txt")
should work just as it is in the immediate window.

If you want to use it in code, you just need something like
Code:
MyDate = FileDateTime("C:\myfile.txt")

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Ok this may make no sense but here is a sample of the code:

Posst.Fields("DateModified").Value = FileDateTime(mypath)

Now, this runs in a loop so it picks up every excel spreadsheet in the mypath location, I have

Posst.Fields("Spreadsheet").Value = myname

to handle the actual spreadsheet name (just the name.XLS)

Every time I get that error.
 
Actually it worked perfectly. Thank you all for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top