show date file updated?

  • Thread starter Thread starter Chris Hughes
  • Start date Start date
C

Chris Hughes

Can I have a field that automatically shows the date when the file was last
updated?
 
You can use code like

Sub LastSaveTime()
With ThisWorkbook
If .FullName <> vbNullString Then
.Worksheets("Sheet1").Range("A1").Value = _
FileDateTime(.FullName)
End If
End With
End Sub


This will put the last saved date and time into cell A1 on Sheet1.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
'-----------------------------------------------------------------
Function DocProps(prop As String)
'-----------------------------------------------------------------
Application.Volatile
On Error GoTo err_value
DocProps = ActiveWorkbook.BuiltinDocumentProperties _
(prop)
Exit Function
err_value:
DocProps = CVErr(xlErrValue)
End Function


and enter in a cell such as
=DocProps ("last author")
or
=DocProps ("last save time")



--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
If you want a function that can be called from a worksheet cell, use

Function LastSaveTime(R As Range) As Date
Application.Volatile True
With R.Worksheet.Parent
If .FullName <> vbNullString Then
LastSaveTime = CDate(FileDateTime(.FullName))
End If
End With
End Function

Then call this from a cell with the formula

=LastSaveTime(A1)

The cell passed to the function doesn't matter. It is used to select the
workbook whose last save time is to be returned.

--
Cordially,
Chip Pearson
Microsoft MVP - Excel, 10 Years
Pearson Software Consulting
www.cpearson.com
(email on the web site)
 
Thanks for that.

Sorry, I'm a code newbie -- how do you put the code into excel to make it a
function?
 
Back
Top