Group:  Microsoft Word ยป microsoft.public.word.mailmerge.fields
Thread: MAIL MERGE

Geek News

MAIL MERGE
Jude2302 6/11/2007 10:20:00 AM
I need to produce a directory/catalog and when the unique ID Number changes
the next set of records should print on a new page. Can someone direct me to
a page that will help me.
Re: MAIL MERGE
"Graham Mayor" <gmayor[ at ]REMOVETHISmvps.org> 6/11/2007 11:21:52 AM
How to use mail merge to create a list sorted by category in Word 2002 -
http://support.microsoft.com/?kbid=294686

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

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

Jude2302 wrote:
[Quoted Text]
> I need to produce a directory/catalog and when the unique ID Number
> changes the next set of records should print on a new page. Can
> someone direct me to a page that will help me.


Re: MAIL MERGE
"Doug Robbins - Word MVP" <dkr[ at ]REMOVECAPSmvps.org> 6/11/2007 8:15:43 PM
If you have the ID Number in the first cell in the one row table in the
directory mail merge main document and then execute that merge to a new
document and then run the following macro, it will create separate tables
with the records for each ID Number in them.

' Macro to create multiple items per condition in separate tables from a
directory type mailmerge

Dim source As Document, target As Document, scat As Range, tcat As Range
Dim data As Range, stab As Table, ttab As Table
Dim i As Long, j As Long, k As Long, n As Long
Set source = ActiveDocument
Set target = Documents.Add
Set stab = source.Tables(1)
k = stab.Columns.Count
Set ttab = target.Tables.Add(Range:=Selection.Range, numrows:=1,
numcolumns:=k - 1)
Set scat = stab.Cell(1, 1).Range
scat.End = scat.End - 1
ttab.Cell(1, 1).Range = scat
j = ttab.Rows.Count
For i = 1 To stab.Rows.Count
Set tcat = ttab.Cell(j, 1).Range
tcat.End = tcat.End - 1
Set scat = stab.Cell(i, 1).Range
scat.End = scat.End - 1
If scat <> tcat Then
ttab.Rows.Add
j = ttab.Rows.Count
ttab.Cell(j, 1).Range = scat
ttab.Cell(j, 1).Range.Paragraphs(1).PageBreakBefore = True
ttab.Rows.Add
ttab.Cell(j + 1, 1).Range.Paragraphs(1).PageBreakBefore = False
For n = 2 To k
Set data = stab.Cell(i, n).Range
data.End = data.End - 1
ttab.Cell(ttab.Rows.Count, n - 1).Range = data
Next n
Else
ttab.Rows.Add
For n = 2 To k
Set data = stab.Cell(i, n).Range
data.End = data.End - 1
ttab.Cell(ttab.Rows.Count, n - 1).Range = data
Next n
End If
Next i


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

"Jude2302" <Jude2302[ at ]discussions.microsoft.com> wrote in message
news:A10AEC1D-A8BC-478D-98FB-836501FE3B7C[ at ]microsoft.com...
[Quoted Text]
>I need to produce a directory/catalog and when the unique ID Number changes
> the next set of records should print on a new page. Can someone direct me
> to
> a page that will help me.


Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net