Thread: [Solved] Mailmerge with grouped data
View Single Post
 
Old 02-02-2015, 04:20 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,929
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Keith Henderson View Post
I can't find the code that keeps printing records on one letter until the Key changes.
Is your mailmerge main document configured for a Directory merge?
Quote:
Originally Posted by Keith Henderson View Post
I also need a better understanding of how/where template text gets folded in to the coding.
The field code provides for text both before and after the repeated records. If you expand the field code for the 'Using One Key' example from page 9 of the tutorial, except for the colouring, you'll see:
Code:
{QUOTE{IF{MERGESEQ}= 1 {SET Key ""} {SET LastKey {REF Key}}}{IF{MERGEFIELD State}<> {REF Key} "{IF{MERGESEQ}> 1 "↵

If you require more details about the above sales figures, please contact your {REF LastKey} Sales Manager.↵

Sincerely,↵


Customer Service Manager (National)↵
{DATE \@ "dddd, d MMMM yyyy"}↵
{IF{MERGEFIELD State}<> 0 {QUOTE 12}}"}{IF{MERGEFIELD State}<> 0 "Director,↵
Retail Sales {MERGEFIELD State}{SET Key {MERGEFIELD State}}↵
↵
These are the sales totals for {MERGEFIELD State \* Charformat}↵
↵
City Representative Sales↵
"}"}"{IF{MERGEFIELD State}<> 0 "{MERGEFIELD City} {MERGEFIELD Representative} {MERGEFIELD Sales \# $,0.00}↵
"}"}
In the above, the:
• green content outputs whatever goes at the start of each letter.
• orange content outputs the repeated data.
• red content outputs whatever goes at the end of each letter (technically, {IF{MERGEFIELD State}<> 0 {QUOTE 12}} is part of that).
• blue QUOTE field generates the page breaks between letters.
• purple fields manage whatever you use as the KEY to indicate a change of grouping.
• black content does the housekeeping, pulling all the others together and ensuring you don't get output being generated at the wrong time.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote