Adding "last saved date" to header

G

Guest

I currently have the following code in order to capture the 'last saved
date', however I need to also add the 'last saved TIME'. What do I need to
add to this in order to capture the time as well?

Thanks in advance for any help!
Cheryl
==================================================
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
ActiveSheet.PageSetup.LeftHeader = "Last Update:" & Date

End Sub
==================================================
 
G

Guest

Hi CherylH,

Just replace the word' date' with 'Now'

ActiveSheet.PageSetup.LeftHeader = "Last Update:" & Now

HTH,
 
G

Guest

The following code checks that active workbook's Last Save Time property to
get the save date. If the document has not been saved the macro exits
without doing anything.

Sub LastSave()

Dim wb As Workbook
Dim ws As Worksheet
Dim dp As DocumentProperty
Dim strLastSave As String
Dim dtmDate As Date

On Error GoTo Err_LastSave

Set wb = ActiveWorkbook
Set dp = wb.BuiltinDocumentProperties("Last Save Time")

strLastSave = dp.Value
If IsDate(strLastSave) Then
dtmDate = CDate(strLastSave)
Else
dtmDate = 0
End If
dtmDate = DateSerial(Year(dtmDate), Month(dtmDate), _
Day(dtmDate))
For Each ws In wb.Worksheets
ws.PageSetup.CenterHeader = "Last Saved On " & dtmDate
Next ws

Exit_LastSave:

Set wb = Nothing
Set ws = Nothing
Set dp = Nothing
Exit Sub

Err_LastSave:

Err.Clear
Resume Exit_LastSave

End Sub
 

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