Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / March 2007

Tip: Looking for answers? Try searching our database.

How do I perform a mail merge into a table?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Polaris - 14 Mar 2007 19:46 GMT
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?
Peter Jamieson - 14 Mar 2007 20:02 GMT
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
> 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
[quoted text clipped - 6 lines]
> So, I suppose my question is, is there a way to dynamically add rows to my
> table as records are needed?
Polaris - 14 Mar 2007 22:46 GMT
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#.
Peter Jamieson - 15 Mar 2007 01:05 GMT
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

> 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#.
Polaris - 15 Mar 2007 05:48 GMT
I tried the directory merge with a template and it put one row per page. Am I
missing something?
Graham Mayor - 15 Mar 2007 07:14 GMT
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.

Signature

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

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

> I tried the directory merge with a template and it put one row per
> page. Am I missing something?
Polaris - 15 Mar 2007 19:58 GMT
That helped. Thanks a lot.
Peter Jamieson - 15 Mar 2007 08:32 GMT
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

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

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.