Help!

How do I perform a mail merge into a table?

 
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> MailMerge Fields RSS
Next:  How do I change numbering scheme from 01 to 001  
Author Message
Polaris
External


Since: Mar 14, 2007
Posts: 7



PostPosted: Wed Mar 14, 2007 3:46 pm    Post subject: How do I perform a mail merge into a table?
Archived from groups: microsoft>public>word>mailmerge>fields (more info?)

What I'd like to do is mail merge from my data source into a Word table.
So, in order to put more than one record on a page, I use the NEXT field
code on each new row. The problem with this is that if I have 20 rows per
page and, say, use only 15, there are now 5 blank, but outlined rows in my
output document. It would of course be easy to remove these rows, but the
entire merge process will be directed by an outside program for automation.

So, I suppose my question is, is there a way to dynamically add rows to my
table as records are needed?
Back to top
Peter Jamieson
External


Since: Aug 10, 2004
Posts: 2188



PostPosted: Wed Mar 14, 2007 8:10 pm    Post subject: Re: How do I perform a mail merge into a table? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

It's possible that instead of using a mailmerge, you could use a DATABASE
field (which, in essence, creates a table in Word from a table or query in a
data source). You don't get a lot of control over the formatting of the
result, but
a. I suggest you have a look at this approach, even if it's just to rule it
out
b. you may be able to deal with some formatting problems by
- formatting the results how you want then
- including a \*Mergeformat switch in the DATABASE field
c. DATABASE fields can sometimes be combined with a mailmerge in useful
ways.

For database fields, look at Word Help, and enable the Database toolbar
(e.g. via Word Tools|Customize) and check the "Insert as field" option when
you insert your data.

Peter Jamieson
"Polaris" wrote in message

> What I'd like to do is mail merge from my data source into a Word table.
> So, in order to put more than one record on a page, I use the NEXT field
> code on each new row. The problem with this is that if I have 20 rows per
> page and, say, use only 15, there are now 5 blank, but outlined rows in my
> output document. It would of course be easy to remove these rows, but the
> entire merge process will be directed by an outside program for
> automation.
>
> So, I suppose my question is, is there a way to dynamically add rows to my
> table as records are needed?
Back to top
Polaris
External


Since: Mar 14, 2007
Posts: 7



PostPosted: Wed Mar 14, 2007 8:10 pm    Post subject: Re: How do I perform a mail merge into a table? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Although that's probably a good idea, I really, really need to use mail
merge, since this document will be needed to be treated in the same way as
labels and letters, in that they will be separate *.doc files, but will be
merged against the same sources programatically in C#.
Back to top
Peter Jamieson
External


Since: Aug 10, 2004
Posts: 2188



PostPosted: Thu Mar 15, 2007 1:07 am    Post subject: Re: How do I perform a mail merge into a table? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Well, the other simple way to merge into a table is to do a
catalog/directory merge where you set up a single table row in your mail
merge main document, with one merge field in each cell.

But you haven't said how you are deciding where your output document is
going to be split, because in that case, you just get one continuous table
with no page breaks etc.

The reason I suggested a DATABASE field is because when you want continuous
tabular output of arbitrary length, that's the way to do it. If you need to
do a merge, then consider using one data source for the merge, with one
record for each "document" you want to produce, and use one DATABASE field
in the mail merge main document that extracts the records related to the
current record in the data source, typically using a key field nested in the
SELECT query in the DATABASE field.

E.g. your data source has records like

sk stext
1 mytexta
2 mytextb
2 mytextc
3 mytextd
3 mytexte
3 mytextf

etc. and you want documents with

mytexta

then
mytextb
mytextc

then
mytextd
mytexte
mytextf

In that case, you can use a data source for the merge such as SELECT
DISTINCT sk FROM mytable, then put a DATABASE field in your Mail Merge Main
Document that does

SELECT stext FROM mytable WHERE sk = { MERGEFIELD sk }

(where { MERGEFIELD sk } is a merge field code and the {} are the special
field braces you can insert using ctrl-F9)

There are problems with this approach, e.g. in recent versions of Word MS
code gets confused between the fields in the data source for the merge and
the fields in tables in the DATABASE field, but you probably either need to
be doing that, or "rolling your own merge" by inserting table rows as
required using C#, in which case your current design won't work either.

Peter Jamieson

"Polaris" wrote in message

> Although that's probably a good idea, I really, really need to use mail
> merge, since this document will be needed to be treated in the same way as
> labels and letters, in that they will be separate *.doc files, but will be
> merged against the same sources programatically in C#.
Back to top
Polaris
External


Since: Mar 14, 2007
Posts: 7



PostPosted: Thu Mar 15, 2007 1:48 am    Post subject: Re: How do I perform a mail merge into a table? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I tried the directory merge with a template and it put one row per page. Am I
missing something?
Back to top
Graham Mayor
External


Since: Jul 04, 2006
Posts: 4874



PostPosted: Thu Mar 15, 2007 7:04 am    Post subject: Re: How do I perform a mail merge into a table? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

See 'How to use mail merge to create a list sorted by category in Word
2002 - http://support.microsoft.com/?kbid=294686' which covers the basics of
a directory merge used to list by groupings. Word is not really designed for
this type of merge.

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

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

Polaris wrote:
> I tried the directory merge with a template and it put one row per
> page. Am I missing something?
Back to top
Peter Jamieson
External


Since: Aug 10, 2004
Posts: 2188



PostPosted: Thu Mar 15, 2007 8:03 am    Post subject: Re: How do I perform a mail merge into a table? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Yes, it probably didn't do what you want because so far you haven't told us
exactly what you want - although I think we probably guessed, and if we
guessed correctly, the other suggestion I made should meet your needs.

Peter Jamieson

"Polaris" wrote in message

>I tried the directory merge with a template and it put one row per page. Am
>I
> missing something?
Back to top
Polaris
External


Since: Mar 14, 2007
Posts: 7



PostPosted: Thu Mar 15, 2007 3:58 pm    Post subject: Re: How do I perform a mail merge into a table? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

That helped. Thanks a lot.
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> MailMerge Fields All times are: Eastern Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum