#1   Report Post  
Posted to microsoft.public.word.newusers
JB[_3_] JB[_3_] is offline
external usenet poster
 
Posts: 17
Default Time stamp

When I close a document I would like to have the time it was saved at the
top of the document. How is that done, please?

JB


  #2   Report Post  
Posted to microsoft.public.word.newusers
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Time stamp

You could use a savedate field eg { SaveDate \@ "HH:mm" } which will record
the last time the document was saved when the document is next opened, but
the field will not update automatically as you make saves to the document
during the course of working - it will however fulfil the basic criterion of
recording the time.

Or you could intercept the FileSave command to add a document variable to
the document and update it each time the document is saved and if you have a
docvariable field in the document - here { DocVariable varSaved } - that
field will display the time the document was saved and update each time you
save.

Sub FileSave()
Dim oVars As Variables
Dim sDate As String
Dim oStory As Range
Dim oField As Field
Set oVars = .Variables
With ActiveDocument
oVars("varSaved").Value = "Last saved at " _
& Format(Time, "hh:mm")
For Each oStory In .StoryRanges
For Each oField In oStory.Fields
If oField.Type = wdFieldDocVariable Then oField.Update
Next oField
Next oStory
.Save
ActiveWindow.Caption = ActiveDocument.FullName
End With
End Sub
http://www.gmayor.com/installing_macro.htm


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




"JB" wrote in message
...
When I close a document I would like to have the time it was saved at the
top of the document. How is that done, please?

JB



  #3   Report Post  
Posted to microsoft.public.word.newusers
JB[_3_] JB[_3_] is offline
external usenet poster
 
Posts: 17
Default Time stamp

Hello Graham

You may remember that you helped m with a Mavro: SaveToTwoLocations. At
the time, I left it at that.

Could I add something to that particular macro, which is working fine, so
that it stamps the time of saving?


Sub SaveToTwoLocations()
Dim oDoc As Document
Dim strFileA As String
Dim strFileB As String
Dim strBackupPath As String
'Define the backup location
strBackupPath = "C:\Documents and Settings\Qimi\Desktop\Backups\"
On Error Resume Next
Set oDoc = ActiveDocument
With oDoc
'Mark the cursor position with a bookmark
.Bookmarks.Add Range:=Selection.Range, Name:="OpenAt"
.Save
strFileA = .FullName
strFileB = strBackupPath & "Backup " & .Name
.Close 'Close the document
End With
FileCopy strFileA, strFileB 'Copy the document
Documents.Open strFileA 'Reopen the original document

ActiveWindow.View.Type = wdPrintView
'and restore the cursor position
ActiveDocument.Bookmarks("OpenAt").Select
End Sub




Thank you








"Graham Mayor" escreveu na mensagem
...
You could use a savedate field eg { SaveDate \@ "HH:mm" } which will
record the last time the document was saved when the document is next
opened, but the field will not update automatically as you make saves to
the document during the course of working - it will however fulfil the
basic criterion of recording the time.

Or you could intercept the FileSave command to add a document variable to
the document and update it each time the document is saved and if you have
a docvariable field in the document - here { DocVariable varSaved } - that
field will display the time the document was saved and update each time
you save.

Sub FileSave()
Dim oVars As Variables
Dim sDate As String
Dim oStory As Range
Dim oField As Field
Set oVars = .Variables
With ActiveDocument
oVars("varSaved").Value = "Last saved at " _
& Format(Time, "hh:mm")
For Each oStory In .StoryRanges
For Each oField In oStory.Fields
If oField.Type = wdFieldDocVariable Then oField.Update
Next oField
Next oStory
.Save
ActiveWindow.Caption = ActiveDocument.FullName
End With
End Sub
http://www.gmayor.com/installing_macro.htm


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




"JB" wrote in message
...
When I close a document I would like to have the time it was saved at the
top of the document. How is that done, please?

JB





  #4   Report Post  
Posted to microsoft.public.word.newusers
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Time stamp

If you mean you want the time written in the document as opposed to in the
filename then the two macros can easily be combined. Put a docvariable field
{ DocVariable varSaved } at the location where you wish the time to appear.

Sub SaveToTwoLocations()
Dim oDoc As Document
Dim strFileA As String
Dim strFileB As String
Dim strBackupPath As String
Dim oVars As Variables
Dim sDate As String
Dim oStory As Range
Dim oField As Field

'Define the backup location
strBackupPath = "C:\Documents and Settings\Qimi\Desktop\Backups\"
On Error Resume Next
Set oDoc = ActiveDocument
With oDoc
Set oVars = .Variables
'Mark the cursor position with a bookmark
.Bookmarks.Add Range:=Selection.Range, name:="OpenAt"
oVars("varSaved").Value = "Last saved at " _
& Format(Time, "hh:mm")
For Each oStory In .StoryRanges
For Each oField In oStory.Fields
If oField.Type = wdFieldDocVariable Then oField.Update
Next oField
Next oStory
.Save
strFileA = .FullName
strFileB = strBackupPath & "Backup " & .name
.Close 'Close the document
End With
FileCopy strFileA, strFileB 'Copy the document
Documents.Open strFileA 'Reopen the original document

ActiveWindow.View.Type = wdPrintView
'and restore the cursor position
ActiveDocument.Bookmarks("OpenAt").Select
End Sub

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



"JB" wrote in message
...
Hello Graham

You may remember that you helped m with a Mavro: SaveToTwoLocations. At
the time, I left it at that.

Could I add something to that particular macro, which is working fine, so
that it stamps the time of saving?


Sub SaveToTwoLocations()
Dim oDoc As Document
Dim strFileA As String
Dim strFileB As String
Dim strBackupPath As String
'Define the backup location
strBackupPath = "C:\Documents and Settings\Qimi\Desktop\Backups\"
On Error Resume Next
Set oDoc = ActiveDocument
With oDoc
'Mark the cursor position with a bookmark
.Bookmarks.Add Range:=Selection.Range, Name:="OpenAt"
.Save
strFileA = .FullName
strFileB = strBackupPath & "Backup " & .Name
.Close 'Close the document
End With
FileCopy strFileA, strFileB 'Copy the document
Documents.Open strFileA 'Reopen the original document

ActiveWindow.View.Type = wdPrintView
'and restore the cursor position
ActiveDocument.Bookmarks("OpenAt").Select
End Sub




Thank you








"Graham Mayor" escreveu na mensagem
...
You could use a savedate field eg { SaveDate \@ "HH:mm" } which will
record the last time the document was saved when the document is next
opened, but the field will not update automatically as you make saves to
the document during the course of working - it will however fulfil the
basic criterion of recording the time.

Or you could intercept the FileSave command to add a document variable to
the document and update it each time the document is saved and if you
have a docvariable field in the document - here { DocVariable
varSaved } - that field will display the time the document was saved and
update each time you save.

Sub FileSave()
Dim oVars As Variables
Dim sDate As String
Dim oStory As Range
Dim oField As Field
Set oVars = .Variables
With ActiveDocument
oVars("varSaved").Value = "Last saved at " _
& Format(Time, "hh:mm")
For Each oStory In .StoryRanges
For Each oField In oStory.Fields
If oField.Type = wdFieldDocVariable Then oField.Update
Next oField
Next oStory
.Save
ActiveWindow.Caption = ActiveDocument.FullName
End With
End Sub
http://www.gmayor.com/installing_macro.htm


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




"JB" wrote in message
...
When I close a document I would like to have the time it was saved at
the top of the document. How is that done, please?

JB







Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Date & Time Stamp dragonfly4959 Microsoft Word Help 4 January 14th 10 07:14 AM
Date & Time Stamp in Track Changes rminato Microsoft Word Help 0 August 25th 08 04:18 PM
track changes time stamp amanda Microsoft Word Help 1 February 14th 08 05:19 PM
Time stamp on tamplates mns Microsoft Word Help 1 January 31st 08 01:57 PM
Time stamp in field codes ctt Microsoft Word Help 3 January 25th 07 04:24 PM


All times are GMT +1. The time now is 03:38 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"