Thread: Time stamp
View Single Post
  #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