Date on a word document

  • Thread starter Thread starter Cimarron AZ
  • Start date Start date
Add a docvariable field at the end of the document {DocVariable varDate}
Use the following macro to update the field.and save the document.
By naming it FileSave it will intercept Word's built-in Save command.

Sub FileSave()
Dim oVars As Variables
Dim oField As Field
Set oVars = ActiveDocument.Variables
oVars("varDate").Value = Format(Date, "dd/MM/yyyy")
For Each oField In ActiveDocument.Fields
If oField.Type = wdFieldDocVariable Then
oField.Update
End If
Next oField
On Error Resume Next
ActiveDocument.Save
End Sub

Set the formatting switch "dd/MM/yyyy" as required.
http://www.gmayor.com/installing_macro.htm


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

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Unfortunately that will update the date whenever you *open* the document and
not when you *update* it.

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

My web site www.gmayor.com

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