Conditional page eject in "Catalogue" mail merge
I was thinking to insert a mailmerge IF ... ELSE before the first
item in the data row, comparing the actual value of the mailmerge
field "Zimmer_Nr" to a DOCVARIABLE, and assign the current value of
the "Zimmer_Nr" to a DOCVARIABLE at the end of the data row.
That is what you have to do but you can't set a DOCVARIABLE from a field so
you have to use SET and REF fields
e.g. put the following at the beginning of your document
{ IF { MERGESEQ } = 1 "{ SET previousZimmer_Nr "{ MERGEFIELD
"Zimmer_Nr" }" }" "" }
Then at the point where you want the page break
{ IF "{ MERGEFIELD "Zimmer_Nr" }" = "{ REF previousZimmer_Nr }" "" "put a
hard page break character here" }{ SET previousZimmer_Nr "{ MERGEFIELD
"Zimmer_Nr" }" }
All the {} need to be the special field braces you can insert using ctrl-F9.
You can probably get rid of a few of the double-quotes, especially if
Zimmer_Nr is always numeric.
A minor problem when using { MERGESEQ } is that it's not set to the current
record number when you preview, only when you actually merge, so the preview
does not necessarily work how you might expect.
Alternatively, if you are executing the merge from VBA, you can consider
using MailMerge events and directly altering the Mail Merge Main Document
when you detect a change in Zimmer_Nr
Peter Jamieson
"Lüko Willms" wrote in message
...
I have a mailmerge of type "catalogue" and want to insert a page
eject when a certain field changes. How do I do that?
Let's say, this controlling field is called "Zimmer_Nr", as German
for Room_No.
I haven't done Winword programming for at least half a year and
can't remember how to do it, but I would need it for tomorrow...
MS-Office 2000, data source is an Excel sheet.
I was thinking to insert a mailmerge IF ... ELSE before the first
item in the data row, comparing the actual value of the mailmerge
field "Zimmer_Nr" to a DOCVARIABLE, and assign the current value of
the "Zimmer_Nr" to a DOCVARIABLE at the end of the data row.
Or can I access the field value indexed by the MERGESEQ value?
Yours,
L.W.
|