Date on a word document

  • Thread starter Thread starter Cimarron AZ
  • Start date Start date
C

Cimarron AZ

How do you format a date to be at the end of a document each time you update
it?
 
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

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
Create a footer, click Insert, Date and Time, check the "update
automatically" box.
 
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

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top