Last Saved Date

G

Guest

I did a search on this subject and found the following code (among others,
but I liked this the best). I am new to VBA and was wandering if someone
could help me out. I noticed that since it runs before you save it is really
posting the second to last save date. I figured out that you can do this
when the sheet calculates, or when the sheet opens, etc., but I wanted to
know what I could replace

ThisWorkbook.BuiltinDocumentProperties("Last Save Time")

with, that would show the current time instead.


Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Sheets("Sheet1").Range("A1").Value =
ThisWorkbook.BuiltinDocumentProperties("Last Save Time")
Sheets("Sheet1").Range("A2").Value =
ThisWorkbook.BuiltinDocumentProperties("Author")
Sheets("Sheet1").Range("A3").Value = Environ("username")
End Sub
 
B

Bob Phillips

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Application.EnableEvents = False
Cancel = True
If SaveAsUI Then
sFile = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
If sFile <> False Then
ThisWorkbook.SaveAs sFile
With Sheets("Sheet1")
.Range("A1").Value = _
ThisWorkbook.BuiltinDocumentProperties("Last Save Time")
.Range("A2").Value = _
ThisWorkbook.BuiltinDocumentProperties("Author")
.Range("A3").Value = Environ("username")
End With
End If
Else
ThisWorkbook.Save
With Sheets("Sheet1")
.Range("A1").Value = _
ThisWorkbook.BuiltinDocumentProperties("Last Save Time")
.Range("A2").Value = _
ThisWorkbook.BuiltinDocumentProperties("Author")
.Range("A3").Value = Environ("username")
End With
End If
Application.EnableEvents = True
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top