mailmerge in header?? catalog type

A

aprendiz

I have a table with employees and projects.
I want to send a letter to every employee whithe their respective projects
in one page or more if they have many projects. I did it with mailmerge
catalog type.
All works fine BUT what I need is not only the list of the projects of every
employee but to write a letter to them. It means put at the top the name of
the employee, then some text, after that the list of projects and lastly a
salutation text.
I far as I know I can't do that in catalog type.
I tried putting the initial text in the header and the salutation in the
footer. That works fine BUT I need to be able to put the employee name in the
header and it is not working.
I hope I am clear if not let me know please.
Thanks in advance.
Aprendiz
 
D

Doug Robbins

This will need a bit more development to achieve exactly what you want, but
it will take the result of a catalog type mailmerge (with in your case the
employee as the first mergefield) created with the mergefields in the cells
of a single row table and create separate tables for each employee with the
employees name in the first row of the table and their projects in the rest
of the rows of the table.

' 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


--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
A

aprendiz

Thanks Doug for your answer!
I am new at this and I will need more help if it is possible.
I've created the directory in a catalog type mailmerge document in this way:

{IF {mergeseq}="1" "{mergefield Employee}" " "}
{SET Employee1 {mergefield Employee}}
{IF {Employee2} <> {Employee1}
......................Page Break..............
"{mergefield Employee}"
{mergefield Project}" "{mergefield Project}" }

When I mailmerge to a new document (called it NEW.doc) I can see my
directory/catalog with an employee and projects in one page.
When I have to use the macro?? in the mailmerge catalog as a macro? or once
I have the NEW document with the results of my catalog mailmerge.
Sorry, it may be a very silly question but I really don't understand.
Aprendriz
 
D

Doug Robbins

You need to re-read the first paragraph of my response and set up the
mailmerge main document in the way described which is completely different
from that which you have used. The macro will only work if the document
created by executing the merge is of the right format.

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
 
A

aprendiz

Thanks a lot Doug!
It took me a while but at the end I understood. :)
It did exactly what I wanted.

Aprendiz
 

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