View Single Post
  #12   Report Post  
Posted to microsoft.public.word.newusers
Graham Mayor
 
Posts: n/a
Default Need help with Field Codes

I'm not really sure where you are going with this. The only way that it
would matter if CREATEDATE was converted to plain text during the merge
(which it is) would be if you wanted to reprint the merged document at a
later date - when it is just as simple to remerge.

Take the following example:
from the merge document

{ CREATEDATE \@ "d MMM yyyy" } ... { ={ CREATEDATE \@ "yyyy"} + 1 }
{ DATE \@ "d MMM yyyy" } ... { ={ DATE \@ "yyyy" } + 1 }
{ MERGEFIELD MergeDate \@ "d MMM yyyy" } ... { ={ MERGEFIELD MergeDate \@
"yyyy" } +1 }

In the merged document

18 Jun 2006 ... { =2006 + 1 }
{ DATE \@ "d MMM yyyy" } ... { ={ DATE \@ "yyyy" } + 1 }
30 Jun 2006 ... { =2006 +1 }

Which prints as

18 Jun 2006 ... 2007
18 Jun 2006 ... 2007
30 Jun 2006 ... 2007

Re-reading your post, it seems to be that Createdate will do what you want.
It produces the date that the *merged* document was created and doesn't
update so there's no need for you to unlink it? Or have I missed something
along the way?

I never merge directly to the printer.


--

Graham Mayor - Word MVP

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



Suzanne S. Barnhill wrote:
I've already backed off somewhat, but do try a CreateDate field,
Graham, before you assert that "date" fields work in mail merges. If
you can find a way to get that to work, I'd be grateful. Here's what
I get:

1. CreateDate in mail merge main document shows creation date of said
document.

2. Merged document shows CreateDate of mail merge main document as
plain text (not a field).

If I use a Date field instead, then the field is preserved in the
merged output, but that's not what I want, though it's a step
forward, since it's easier to Ctrl+Shift+F9 to unlink the field than
to type the date in manually. The document in question is a list of
phone numbers for the members of my Rotary club; I create a new list
whenever the membership changes, so I want it to show the revision
date. I guess maybe the SaveDate is what I need to shoot for (now
that I know there is a possibility of getting some kind of date field
to work).


"Graham Mayor" wrote in message
...
I'm not sure what Suzanne is thinking of here, but date and
calculation fields do work in mail merge.

You need CTRL+F9 for *each pair* of curly brackets and you need to
end up with the following

{ ={ DATE \@ "yyyy" } +1 } which currently will give you 2007. Press
F9 to update the field.

For more complex date calculations, see
http://www.gmayor.com/insert_a_date_...than_today.htm and for
formatting, see http://www.gmayor.com/formatting_word_fields.htm

--

Graham Mayor - Word MVP

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


Rhino wrote:
So you're saying that there's no way to put the current year plus 1
(whatever the current year is when I run the mail merge) in each
label of a set of labels? No way at all?? Are you sure?

I find that surprising: Word seems pretty powerful and the task of
putting a date on each label seems pretty trivial. By the way, I can
put the current date on a label easily enough, it's just the result
of adding 1 to the current year that is giving me trouble.
Considering that you can calculate quantities like the current year
plus 1 in other places within the document, why not do the same in a
mail merge?
By the way, I was able to get past the Syntax Error problem I
reported earlier. I now have perfectly valid looking code that
doesn't give me an error message:

{ DATE = {={DATE \@ yyyy} + 1}}

However, although the expression seems to be calculating the current
year plus 1, the result of the calculation always seems to be the
current year NOT the current year plus 1. For what it's worth, I
have tried umpteen variations of this formula, some of which used
CREATEDATE instead of DATE and some of which used "yyyy" instead of
yyyy, but I always get the current year, not current year plus 1.
I've tried adding numbers much greater than 1 - on the theory that 1
might have been interpreted as 1 millisecond instead of 1 year in
this expression - but even with huge numbers like 99999999999999999,
the result of the addition is always the current year.

"Suzanne S. Barnhill" wrote in message
...
You did not mention a mail merge. Date fields are not compatible
with mail merges.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so
all may benefit.

"Rhino" wrote in message
...
There's got to be some kind of a knack that I'm just not getting
here. I tried doing a CTRL-F9 to produce a pair of heavy braces
at the right point in my document. That worked. Then, when I
pasted the exact string you provided in your note, including the
spaces, that seemed to work too. But as soon as I pressed the
"Propagate" icon
on the Mail Merge toolbar, the spot
where I had entered the field code said !Syntax Error, {.

VENT
I've been messing with this seemingly simple task of inputting a
formula for calculating the next year for something like two hours
and my head's getting sore from banging it on the wall. I seem to
have tried every variation I can imagine of DATE, SET, =, and
everything else I could think of and it inevitably gets me a
syntax error!! What the heck is going on here?? I've done a
Google search
on the newsgroup and seen several variations of your suggestion
supplied by various responders and none of them seem to have any
followup questions, which gives the impression that the original
poster had no problem using this formula in their documents. So
why do I alone seem to have problems with this?? Is there some
kind of document wide setting that has the wrong value or
something?? /VENT

For what it's worth, I've also tried doing Insert/Field, selecting
=, then
entering { DATE \@ "YYYY" } +1
in the Formula field, then choosing 0 as the number format. That
doesn't work either. I've tried using lowercase "yyyy" instead of
"YYYY". That didn't help. Everything leads me back to this Syntax
Error. What boneheaded mistake am I making here?

--
Rhino



"Suzanne S. Barnhill" wrote in message
...
No need for a QUOTE field. This works just fine for me (Word
2003) with this
syntax:

{ = { DATE \@ "YYYY" } +1 }

Note the spaces.


--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so
all may benefit.

"Rhino" wrote in message
...
I'm trying to put a field code into my Word 2002 document but
having trouble getting the syntax just right.

I want the field code to be replaced by the current year plus 1.
Therefore, if the document is being generated today, I want the
field code to put 2007 at a specifc place within my document.

I know that the field code {DATE \@ "YYYY"} will give me the
current year.

I'm struggling with how to write the field code that will give
me the next
year. First of all, I'm not sure whether I can write an
expression that
adds
1 to year and display that result directly or whether I have to
first transform that result to a character string. Second, I'm
not sure how to get the result even as an integer.

To get an integer result, I'm guessing that I have to use an =
formula,
something like this:

{={DATE \@ "YYYY"}+1}

To get a character string result, I'm guessing that I have to
imbed all
of
that in a QUOTE, something like this:

{QUOTE "{={DATE \@ "YYYY"} +1}/1 \@ "YYYY"}

This last guess was inspired by the Help article on QUOTE.

Unfortunately, I inevitably get a Syntax Error whenever I try to
use either approach, no matter how carefully I try to write the
field code. (I'm a
veteran programmer and I know how important it is to get the
syntax of a statement just right.) What's worse is that
everytime I get the Syntax Error, the original field code is
destroyed and I have to painstakingly
type
it all in again rather than just altering it and trying it
again.

Can anyone help me out?

--
Rhino