Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / February 2008

Tip: Looking for answers? Try searching our database.

Document Date

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Stammers - 21 Feb 2008 10:28 GMT
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
Doug Robbins - Word MVP - 21 Feb 2008 11:54 GMT
I would have thought that the date on which the document was created as
results from the use of the CREATEDATE field would be the date that you want
on the letter.  If for some reason that is not, the you would need to unlink
the date field, by selecting it (or the whole document and using
Ctrl=Shift+F9.  That of course could be done by the use of some VBA code.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Hello,
>
[quoted text clipped - 20 lines]
> Thanks,
> Chris
Graham Mayor - 21 Feb 2008 15:35 GMT
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

Signature

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

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

> Hello,
>
[quoted text clipped - 14 lines]
> Thanks,
> Chris
Peter Jamieson - 21 Feb 2008 15:51 GMT
CREATEDATE may do it if you have the right starting point (probably a
template rather than a document).

But if not, when you get data from the AS400, can you specify a SQL Query
that lists a function like today() as one of the fields, in addition to the
fields you're getting from the data source? (I don't know what facilities
are on offer in AS400-land)

If not, you can probably use the technique described in

http://tips.pjmsn.me.uk/t0004.htm

to insert today's date (e.g. using the date() function) and destroy the
field during the merge.

Ideally you would be able to use just one DATABASE field to return the value
formatted exactly as you want it, but since there's a problem whereby Word
now adds a paragraph mark to the result of a DATABASE field, you'll probably
need either
a. two copies of the same DATABASE field (so you can apply the two separate
formats you are using at the moment) or
b.
{ SET today { DATABASE ... } }
then
{ REF today \@ "d" \*ordinal } { REF today \@ "MMMM yyyy }

etc.

Haven't tried that specific approach, and the DATABASE field won't work
inside tables.

Signature

Peter Jamieson
http://tips.pjmsn.me.uk

> Hello,
>
[quoted text clipped - 20 lines]
> Thanks,
> Chris
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.