Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Maanu Maanu is offline
external usenet poster
 
Posts: 33
Default Update Date automatically

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!

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Update Date automatically

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" wrote in message
...
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!



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Update Date automatically

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" wrote in message
...
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!



Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Word 2002: Macro w/today's date - update date automatically MTKathy Microsoft Word Help 1 March 13th 08 10:50 PM
Can I Insert a date that will automatically update when opened to 1MONTH FROM CURRENT DATE? Dori New Users 2 February 21st 08 10:22 PM
How to Automatically Update the Date EB Microsoft Word Help 1 September 4th 07 03:25 PM
Automatically date and time update Jo Newall Microsoft Word Help 1 July 26th 07 06:17 AM
Date/Time will not automatically update. loates Microsoft Word Help 6 April 10th 06 10:45 PM


All times are GMT +1. The time now is 11:16 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"