Thread: Document Date
View Single Post
  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Document Date

If you have a merge document with DATE fields, a merge to a new document
will retain the Date field format and always show the system date (the
problem you currently have).
If you have a merge document with CREATEDATE fields a merge to a new
document will always show the date in the merge document, which is what you
are finding.

To get around this you have three choices.

1. Use SaveAs to save the merge document with the same filename then update
the CREATEDATE fields *before* merging

Sub UpdateCreateDate()
Dim sfName As String
Dim strCodes As String
Dim iFld As Integer
sfName = ActiveDocument.FullName
ActiveDocument.SaveAs FileName:=sfName, FileFormat:=wdFormatDocument
Selection.HomeKey
For iFld = ActiveDocument.Fields.Count To 1 Step -1
With ActiveDocument.Fields(iFld)
If .Type = wdFieldCreateDate Then
.Update
End If
End With
Next iFld
End Sub

OR

2. Keep the DATE fields and run a macro to replace the DATE fields with
CREATEDATE fields in the new document

Sub ChangeFieldContent()
Dim strCodes As String
Dim iFld As Integer
Dim strFind As String
Dim strRepl As String
Selection.HomeKey
For iFld = ActiveDocument.Fields.Count To 1 Step -1
With ActiveDocument.Fields(iFld)
If .Type = wdFieldDate Then
.Code.Text = Replace(UCase(.Code.Text), _
"DATE", "CREATEDATE")
End If
End With
Next iFld
End Sub

OR
3 Unlink the DATE fields in the merged document

Sub UnlinkDateField()
Dim strCodes As String
Dim iFld As Integer
Selection.HomeKey
For iFld = ActiveDocument.Fields.Count To 1 Step -1
With ActiveDocument.Fields(iFld)
If .Type = wdFieldDate Then
.Unlink
End If
End With
Next iFld
End Sub


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


Chris Stammers wrote:
Hello,

I am using Word 2002 and I have a problem with the { DATE } field.
Our data source is an AS400 platform that doesn't contain the date a
record was created therefore I have been using the following: { DATE
\@ "d" \*ordinal } { DATE \@ "MMMM yyyy }. This is OK however we have
an automatic scanning facility which is used to recall letters if a
customer wants a copy. This has to have the original date the letter
was produced and unfortunately, the above field will always show the
current days date. Is there a field switch I can use to hardcode the
date the letters are generated through the merge? I have tried
CREATEDATE and SAVEDATE; CREATEDATE only ever returns the date the
document was created (obviously, perhaps). SAVEDATE would be prone to
changing if something in the document changes after it has been
opened. Any suggestions?

Thanks,
Chris