Insert a separator page when a record changes

B

blake.keller

I am trying to get Word 07 mail merge to insert a separator page
between changes in a certain field in a set of records. My data
source has records that have a field that changes about every 20 to
thirty lines. When that field changes, I need Word to drop in a
seperator page with the new value of that field. Example: The name
Mr. Smith may appear 24 times in a row then change to Mr. Jones, when
this occurs I need a seperator page inserted.

I know that VDP products like PrintShop Mail can do this but the
information that I am printing is so simple it is hard to justify the
cost. Any help would be greatly appreciated.
 
M

macropod

Hi Blake,

The following field coding shows how to conditionally insert a new page, using a mergefield whose name is 'Data' (substitute with
your own field name):
{IF{MERGEREC}= 1 {SET OldValue {MERGEFIELD Data}} {IF{MERGEFIELD Data}= {OldValue} "" "{QUOTE 12}{SET OldValue {MERGEFIELD Data}}"}}
Note that all the braces shown in the above a field braces, which you create in pairs via Ctrl-F9 - you can't simply type them in or
copy them from this post. Also, pay special attention to the spacing. The page break is created by the {QUOTE 12} field - you could
insert an actual page break into the code at this point instead.

Cheers
 
B

blake.keller

Hi Blake,

The following field coding shows how to conditionally insert a new page, using a mergefield whose name is 'Data' (substitute with
your own field name):
{IF{MERGEREC}= 1 {SET OldValue {MERGEFIELD Data}} {IF{MERGEFIELD Data}= {OldValue} "" "{QUOTE 12}{SET OldValue {MERGEFIELD Data}}"}}
Note that all the braces shown in the above a field braces, which you create in pairs via Ctrl-F9 - you can't simply type them in or
copy them from this post. Also, pay special attention to the spacing. Thepage break is created by the {QUOTE 12} field - you could
insert an actual page break into the code at this point instead.

Cheers






- Show quoted text -

Thanks for the help. That appears to be getting me on the right track
but the page breaks are appearing just before the section break in
each merged letter and not actually inserting a blank page except for
the end of the merged document. I can supply a copy of the merge form
and a sample database if that would help. Thanks again.
 
B

blake.keller

Great! Thanks for the help. The other question that I have is there
a way to get a a certain field to only print on those separator
pages? Also, how can I configure Word to give those separator pages a
different size than the normal pages. The normal pages are 12"x16"
and I would like to make the seperator pages be 13"x16". My printer
will handle tray calls as it will know what paper is where. Thanks
again for your help.
 
D

Doug Robbins - Word MVP

It might be easier to execute the merge to a new document, then use a
modification of a macro such as

Sub splitter()
' splitter Macro
' Macro created by Doug Robbins to save each letter created by a mailmerge
' as a separate file, retaining the header and footer information.
Dim i As Long, Source As Document, Target As Document, Letter As Range
Set Source = ActiveDocument
For i = 1 To Source.Sections.Count
Set Letter = Source.Sections(i).Range
Set Target = Documents.Add
Target.Range = Letter
Target.Sections(2).PageSetup.SectionStart = wdSectionContinuous
Target.SaveAs FileName:="Letter" & i
Target.Close
Next i
End Sub

to split that document into separate files into each of which the separator
page was inserted (by inserting a NextPage Section Break at the beginning of
the document and formatting the then first page of the document so that it
was the desired sizze) and have it print the file without being saved. If
the mergefield that will contain the data that is to appear on the separator
page was the first paragraph of the mailmerge main document, the macro could
cut the corresponding paragraph from each file and paste it onto the
separator page.


--
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
 

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