Date field only update if document has been updated

  • Thread starter Kim W. via OfficeKB.com
  • Start date
K

Kim W. via OfficeKB.com

Ok, this may be simple... but I haven't figured it out yet. I only want the
date/time field in my footer to update if a change to the document has been
made. I don't want it to change when the document opens. I don't want it to
change when it's printed. I don't need the createdate field... that doesn't
work... so.. is there anything I can do?

Thanks!

Kim
 
G

Graham Mayor

You could use the savedate field. However most fields do not update
automatically and if you updated the savedate field after saving to display
its revised content, the document would need to be saved again ad infinitum.
It should however show the correct date the next time the document is
opened.

You could work around this with a couple of macros in the document template,
then replace the field in the document with the docvariable field {
DocVariable varSaveDate }. The macros update a document variable with the
current date before saving. You can change the date formatting switches
"dd/MM/yyyy" to suit your local preference.

http://www.gmayor.com/installing_macro.htm

Sub FileSave()
Dim oVars As Variables
Dim oField As Field
Set oVars = ActiveDocument.Variables
oVars("varSaveDate").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
ActiveWindow.Caption = ActiveDocument.FullName
End Sub

and

Sub FileSaveAs()
Dim oVars As Variables
Dim oField As Field
Set oVars = ActiveDocument.Variables
oVars("varSaveDate").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
Dialogs(wdDialogFileSaveAs).Show
ActiveWindow.Caption = ActiveDocument.FullName
End Sub


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


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

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

Top