How do I create a merge field that will do the following?

S

sokab

I need to create a Word mergefield that will return last month's name and
year. For example: We are currently in the month of September. When the
field is merged, it will return "August 2007". If the letter is merged in
October, the field will return "September 2007".
 
D

Dav

Hi There

Here is my proposal

{IF {MERGEDATE \@ "MM"} = 1 "December {DATE \@ "yyyy"}" "{IF {MERGEDATE \@
"MM"} = 2 "January {DATE \@ "yyyy"}" "{IF{MERGEDATE \@ "MM"} = 3 "February
{DATE \@ "yyyy"}" "'{IF {MERGEDATE \@ "MM"} = 4 "March {DATE \@ "yyyy"}"
"{IF {MERGEDATE \@ "MM"} = 5 "April {DATE \@ "yyyy"}" "{IF {MERGEDATE \@
"MM"} = 6 "May {DATE \@ "yyyy"}" "{IF {MERGEDATE \@ "MM"} = 7 "June {DATE \@
"yyyy"}" "{IF {MERGEDATE \@ "MM"} = 8 "July {DATE \@ "yyyy"}" "{IF
{MERGEDATE \@ "MM"}= 9 "August {DATE \@ "yyyy"}" "{IF {MERGEDATE \@ "MM"} =
10 "September {DATE \@ "yyyy"}" "{IF {MERGEDATE \@ "MM"} = 11 "October {DATE
\@ "yyyy"}" "{IF {MERGEDATE \@ "MM"} = 12 "November {DATE \@ "yyyy"}"
""}"}"}"}"}"}"}"}"}"}"}"}

Insert all {} using Ctrl+F9

Hope it helps (hope it works too ;o))

Greetings from France

Dav
 
M

macropod

Hi sokab,

A simple field construction like:
{QUOTE
{SET Delay -1}
{SET MDATE {MERGEFIELD SourceDate}}
{SET m{=MOD({MDATE \@ MM}+Delay+11,12)+1}}
{SET y{=INT({MDATE \@ yyyy}+(Delay+{MDATE \@ M}-1)/12)}}
"{m}-{y}" \@ "MMMM yyyy"}
will return the month and year. But - do you want just the month and year, or the day, month and year (taking account of different
month lengths)?

Whichever it is you can see how to do that and just about everything else you might want to do with dates in Word, in my Date Calc
'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=249902
or
http://www.gmayor.com/downloads.htm#Third_party
In particular, look at the topic titled 'Automatically insert a past or future date'.

Cheers
 
D

Dav

Hi Macropod

macropod said:
Hi sokab,

A simple field construction like:
Whichever it is you can see how to do that and just about everything else
you might want to do with dates in Word, in my Date Calc 'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=249902

Sadly, this link doesn't work

Dav

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

sokab said:
I need to create a Word mergefield that will return last month's name and
year. For example: We are currently in the month of September. When the
field is merged, it will return "August 2007". If the letter is merged
in
October, the field will return "September 2007".
 
G

Graham Mayor

Use the second link http://www.gmayor.com/downloads.htm#Third_party as WOPR
is down at present.

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Hi Macropod

macropod said:
Hi sokab,

A simple field construction like:
Whichever it is you can see how to do that and just about everything
else you might want to do with dates in Word, in my Date Calc
'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=249902

Sadly, this link doesn't work

Dav

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

sokab said:
I need to create a Word mergefield that will return last month's
name and year. For example: We are currently in the month of
September. When the field is merged, it will return "August 2007".
If the letter is merged in
October, the field will return "September 2007".
 
D

Dav

Hi Graham

Really great. Thanks.
And really very interesting !

Dav

Graham Mayor said:
Use the second link http://www.gmayor.com/downloads.htm#Third_party as
WOPR is down at present.

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Hi Macropod

macropod said:
Hi sokab,

A simple field construction like:
Whichever it is you can see how to do that and just about everything
else you might want to do with dates in Word, in my Date Calc
'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Number=249902

Sadly, this link doesn't work

Dav

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

I need to create a Word mergefield that will return last month's
name and year. For example: We are currently in the month of
September. When the field is merged, it will return "August 2007".
If the letter is merged in
October, the field will return "September 2007".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top