Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15
Default Adding "last saved date" to header

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
==================================================
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 180
Default Adding "last saved date" to header

Hi CherylH,

Just replace the word' date' with 'Now'

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

HTH,
--
Pranav Vaidya
VBA Developer
PN, MH-India
If you think my answer is useful, please rate this post as an ANSWER!!


"CherylH" wrote:

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
==================================================

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,316
Default Adding "last saved date" to header

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

--
Kevin Backmann


"CherylH" wrote:

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
==================================================

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a "last saved on date/user" macro/function for Excel 2003 Zliz Excel Discussion (Misc queries) 2 January 2nd 07 10:12 PM
"Last Saved" date in Excel 2000 Rachael Excel Worksheet Functions 11 September 21st 06 05:50 PM
Solution "Your changes could not be saved" "The document may be read-only or encrypted" [email protected] Excel Discussion (Misc queries) 0 August 7th 06 06:31 AM
how do I insert "last saved date" in as a field in excel? chirag Excel Worksheet Functions 5 February 15th 06 05:42 PM
.csv drops "0" when saved, even if file was set as "text". TRminator Excel Discussion (Misc queries) 3 November 2nd 05 02:11 PM


All times are GMT +1. The time now is 07:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"