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 / February 2006

Tip: Looking for answers? Try searching our database.

Multiple sub-entries for one main entry

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Greg Maxey - 07 Feb 2006 00:26 GMT
Mailmerge is definitely not my strong suit.  I became curious today to learn how to do a specific task.  

Say I have an Excel spread sheet with names in column A
and some other data in column B.  Because there can be one or more data elements in Column B, some of the A cells are blank.  Like this:

Name               Fav Color
Fred                 Red
                       White
                       Blue
Bill                   Green
                       Yellow
Mary                Purple
                       Gold

Could I use this construction in some way to create a mailmerge like:

Dear Fred,

Your favority colors are red, white, and blue

Dear Bill

Your favorite colors are green and yellow.

Etc.

If not, how would I have to layout the datasource to achieve this.  Thanks.
Peter Jamieson - 07 Feb 2006 01:38 GMT
Hi Greg,

Mailmerge is not really up to this kind of "one-to-many" task. It is
possible to do some stuff - e.g. have a look at CIndy Meister's site at
http://homepage.swissonline.ch/cindymeister/, specifically the Mail Merge
FAQ, Special merges, "Multiple items per condition". For the specific
example you mention, I'd be more inclined to do a first pass of some kind,
possibly using VBA and ADO to generate the data source I really needed -
i.e. probably one which had one record for each name in column A and the
exact text I wanted to stuff in in another column.

Peter Jamieson

Mailmerge is definitely not my strong suit.  I became curious today to learn
how to do a specific task.

Say I have an Excel spread sheet with names in column A
and some other data in column B.  Because there can be one or more data
elements in Column B, some of the A cells are blank.  Like this:

Name               Fav Color
Fred                 Red
                       White
                       Blue
Bill                   Green
                       Yellow
Mary                Purple
                       Gold

Could I use this construction in some way to create a mailmerge like:

Dear Fred,

Your favority colors are red, white, and blue

Dear Bill

Your favorite colors are green and yellow.

Etc.

If not, how would I have to layout the datasource to achieve this.  Thanks.


Greg Maxey - 07 Feb 2006 01:57 GMT
Thanks Peter.

It doesn't appear to be a straight forward process.  Since it was just a
whim, I don't think that I am prepared to go wallowing into dark waters.

Cheers

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Hi Greg,
>
[quoted text clipped - 39 lines]
> If not, how would I have to layout the datasource to achieve this.
> Thanks.
Doug Robbins - Word MVP - 07 Feb 2006 04:52 GMT
I thought that "wallowing in dark waters" was what submariners do.

See the "Group Multiple items for a single condition" item on fellow MVP
Cindy Meister's website at

http://homepage.swissonline.ch/cindymeister/mergfaq1.htm#DBPic

Or take a look at the following Knowledge Base Articles

http://support.microsoft.com/default.aspx?scid=kb;en-us;302665

http://support.microsoft.com/default.aspx?scid=kb;en-us;294686

Or, if you create a Catalog (on in Word XP and later, it's called Directory)
type mailmerge main document with the mergefields in the cells of a one row
table in the mailmerge main document with the keyfield in the first cell in
the row 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
key field in them.  With a bit of further development, you may be able to
get it to do what you want.

' 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

Signature

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

> Thanks Peter.
>
[quoted text clipped - 46 lines]
>> If not, how would I have to layout the datasource to achieve this.
>> Thanks.
Greg Maxey - 07 Feb 2006 10:54 GMT
Doug,

The diving alarm is sounded and I am inspired.  I will look at this material
further.  Thanks.

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> I thought that "wallowing in dark waters" was what submariners do.
>
[quoted text clipped - 112 lines]
>>> If not, how would I have to layout the datasource to achieve this.
>>> Thanks.
Greg - 07 Feb 2006 16:33 GMT
Doug,

Cracked it!!! Thanks for the nudge.

I adpated the Q211303 method as follows to meet my needs:

{ SET Name1 { MF Name }}{ IF { MERGESEQ } = "1""{ IF { Name1 } =
"""<enter>
{ MF Donations }"<enter>
"Name:  { MF Name } Address:  { MF Address }<enter>
<enter>
{ MF Donations }"} ""{ IF { Name1 } = """<enter>
{ MF Donations }"<enter>
"<enter>
<Page Break>
Name:  { MF Name } Address:  { MF Address }<enter>
<enter>
{ MF Donations }"} " }<enter>

MF stands in for the full text MERGEFIELD in the actual field code.

This works for an EXCEL spreadsheet laid out as:

Name             Address             Donations
Bill Miller        123 Cherry St.    $60.00
                                             $40.00
                                             $25.00
Mary Poppins 456 Pine St.       $100.00
                                             $50.00
Tom Sawyer  ....

where the blank spaces are empter mergefields.

Thanks again.
 
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.