From: Maanu on 6 Apr 2010 23:10 Hi, I have a word document. It has a date field which indicates when the document was last saved. Is it possible to update this field automatically whenever somebody saves the file? Thanks!
From: Graham Mayor on 7 Apr 2010 01:32 No - most fields do not update automatically and if you updated the savedate field after saving, 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 My web site www.gmayor.com Word MVP web site http://word.mvps.org <>>< ><<> ><<> <>>< ><<> <>>< <>><<> "Maanu" <Maanu(a)discussions.microsoft.com> wrote in message news:2DBDC374-8FDC-45E4-8A2F-40C37E11DFA8(a)microsoft.com... > Hi, > > I have a word document. It has a date field which indicates when the > document was last saved. > > Is it possible to update this field automatically whenever somebody saves > the file? > > Thanks! >
|
Pages: 1 Prev: Inspect Document Word 2007 Next: Where can I find the ASL interpreting symbol I can download? |