R
R Douglas
Hi all,
The function FileDateTime returns "the date and time when a file was created
or last modified." But it doesn't seem to work (the way I thought it would)
when the file is an open XLS workbook.
I would like to put in a cell, the date of my excel file was last modified
and last saved to disk. I thought that this would do it:
Sub TestDate()
fileSpec = ThisWorkbook.FullName
Dim myDate As String
myDate = FileDateTime(fileSpec)
Range("A1").Value = myDate
End Sub
But this gets the date and time the file was opened. How do I get the date
when the file was saved to disk (like the "Last Modified" date in Windows
Explorer)?
I've also tried
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(fileSpec)
Range("A2").Value = fileSpec + " " + Str(f.DateLastModified)
Range("A3").Value = fileSpec + " " + Str(f.DateLastAccessed)
Range("A4").Value = fileSpec + " " + Str(f.DateCreated)
but DateLastModified and DateLastAccessed are always the same - the date the
file was opened.
Thanks in advance,
The function FileDateTime returns "the date and time when a file was created
or last modified." But it doesn't seem to work (the way I thought it would)
when the file is an open XLS workbook.
I would like to put in a cell, the date of my excel file was last modified
and last saved to disk. I thought that this would do it:
Sub TestDate()
fileSpec = ThisWorkbook.FullName
Dim myDate As String
myDate = FileDateTime(fileSpec)
Range("A1").Value = myDate
End Sub
But this gets the date and time the file was opened. How do I get the date
when the file was saved to disk (like the "Last Modified" date in Windows
Explorer)?
I've also tried
Dim fso, f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(fileSpec)
Range("A2").Value = fileSpec + " " + Str(f.DateLastModified)
Range("A3").Value = fileSpec + " " + Str(f.DateLastAccessed)
Range("A4").Value = fileSpec + " " + Str(f.DateCreated)
but DateLastModified and DateLastAccessed are always the same - the date the
file was opened.
Thanks in advance,