Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
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. |
#2
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
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 "Greg Maxey" wrote in message ... 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. |
#3
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
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 -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. "Peter Jamieson" wrote in message ... 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 "Greg Maxey" wrote in message ... 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. |
#4
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
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/cindy...faq1.htm#DBPic Or take a look at the following Knowledge Base Articles http://support.microsoft.com/default...b;en-us;302665 http://support.microsoft.com/default...b;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 -- 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 "Greg Maxey" wrote in message ... 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 -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. "Peter Jamieson" wrote in message ... 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 "Greg Maxey" wrote in message ... 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. |
#5
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Doug,
The diving alarm is sounded and I am inspired. I will look at this material further. Thanks. -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. Doug Robbins - Word MVP wrote: 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/cindy...faq1.htm#DBPic Or take a look at the following Knowledge Base Articles http://support.microsoft.com/default...b;en-us;302665 http://support.microsoft.com/default...b;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 "Greg Maxey" wrote in message ... 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 -- Greg Maxey/Word MVP See: http://gregmaxey.mvps.org/word_tips.htm For some helpful tips using Word. "Peter Jamieson" wrote in message ... 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 "Greg Maxey" wrote in message ... 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. |
#6
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
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. |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
LInking Fields / Populate multiple instances from one entry | Microsoft Word Help | |||
ENTERING MULTIPLE ENTRIES | Microsoft Word Help | |||
Merging multiple records on same main document until a field chang | Microsoft Word Help | |||
How do I make multiple entry labels in word 2003? | Microsoft Word Help | |||
Deleting multiple Word Index Entries | New Users |