Place the document save date and time in the name of the word docu

  • Thread starter Thread starter cdellert
  • Start date Start date
C

cdellert

Does anyone know of a way to place the document save date and time in the
name of the word document automatically when the document is saved?
 
One answer is to use a savedate field with a date and time switch eg

{ SaveDate \@ "MMM d, YYYY hh:mm" }

but if you want automatic updating you will need a couple of macros in the
document template to intercept the save and save as routines and update the
field eg as follows. If there is no savedate field in the document the
routines will simply save the document.

Sub FileSave()
Dim iFld As Long
ActiveDocument.Save
For iFld = 1 To ActiveDocument.Fields.Count
With ActiveDocument.Fields(iFld)
If .Type = wdFieldSaveDate Then
.Update
End If
End With
Next iFld
End Sub


Sub FileSaveAs()
Dialogs(wdDialogFileSaveAs).Show
ActiveWindow.Caption = ActiveDocument.FullName
Dim iFld As Long
For iFld = 1 To ActiveDocument.Fields.Count
With ActiveDocument.Fields(iFld)
If .Type = wdFieldSaveDate Then
.Update
End If
End With
Next iFld
End Sub

http://www.gmayor.com/installing_macro.htm
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Graham, thanks for replying to this post... Does this actually save the save
date and time in the name of the file?
 
I'm sorry, I misread your question. No, it does not as you have no doubt
discovered :o(

If you want to save a document with the date and name in the filename as
opposed to within the documnent, you need a different approach.

See my web page http://www.gmayor.com/save_numbered_versions.htm which you
could modify to your requirements.

To include the time and set a US date format you will need to modify the
line
strDate = Format((Date), "dd MMM yyyy")
to
strDate = format(Now, "MMM dd yyyy hh mm")

Note that you cannot use reserved characters in a filename so you would not
be able to put a colon between hh:mm
If the function is to be shared and you want to include the numbering (which
I recommend to avoid overwriting documents saved within the same minute and
thus having the same name) then use the second version of the macro. This
uses a shared start-up folder to store the incrementing number.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Back
Top