Group:  Microsoft Word ยป microsoft.public.word.mailmerge.fields
Thread: Insert line into catalog mail merge

Geek News

Insert line into catalog mail merge
EricK 5/22/2007 7:49:00 PM
I have set up a catalog mail merge in Word 2000 from an Excel worksheet. One
of the fields is a date and I have sorted on that.

Is there any way to get Word to automatically put a line between any two
rows where the date changes? Ideally I mean a solid line, but an empty row
would do.
So
record1 1 May 2007
record2 1 May 2007
record3 2 May 2007
etc

would become something like
record1 1 May 2007
record2 1 May 2007
-----------------------
record3 2 May 2007
etc

Thanks,

Eric
Re: Insert line into catalog mail merge
"Doug Robbins - Word MVP" <dkr[ at ]REMOVECAPSmvps.org> 5/22/2007 8:32:46 PM
You could modify the following macro to do that:

' 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

"EricK" <EricK[ at ]discussions.microsoft.com> wrote in message
news:E155A7C3-106E-4F71-92B1-37C561CD525B[ at ]microsoft.com...
[Quoted Text]
>I have set up a catalog mail merge in Word 2000 from an Excel worksheet.
>One
> of the fields is a date and I have sorted on that.
>
> Is there any way to get Word to automatically put a line between any two
> rows where the date changes? Ideally I mean a solid line, but an empty row
> would do.
> So
> record1 1 May 2007
> record2 1 May 2007
> record3 2 May 2007
> etc
>
> would become something like
> record1 1 May 2007
> record2 1 May 2007
> -----------------------
> record3 2 May 2007
> etc
>
> Thanks,
>
> Eric


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