#1
|
|||
|
|||
Directory Mail Merge with table layout
Hi all,
I am trying to perform a Directory type Mail Merge from Excel into Word where the data being referenced in Excel has repeated values in one column which I effectively want to group on so that I produce one document per value in that column instead of one column per record in the range. The Directory Mail Merge option seems to work perfectly for this and by following some instructions online I have been able to successfully get the merge to work. However, I have one final layout issue which is bugging me and I can't seem to get it to work properly. If I give a simplified example of what I am doing, perhaps this will make more sense. Say I have the following data in my Excel sheet in the range which is being specified in my Mail Merge: Code:
Customer Site Item Charge1 Charge2 Charge3 -------- ---- ---- ------- ------- ------- Customer 1 Little Place Widget 45.00 75.00 95.00 Customer 1 Medium Road Widget 40.00 70.00 98.00 Customer 1 Medium Road Thing 48.00 76.00 92.00 Customer B Red Street Widget 35.00 72.00 90.00 Customer B Blue Avenue Widget 42.00 78.00 87.00 Customer B Blue Avenue Thing 41.00 68.00 85.00 Customer B Green Drive Widget 38.00 65.00 91.00 Customer $ Square Crescent Widget 39.00 62.00 90.00 Customer $ Circle Way Widget 34.00 60.00 96.00 So effectively I check to see if I am merging the first item in the merge sequence, outputting the start of a letter if I am, which contains the Dear [x] line and the table header row. Then I use some logic to determine whether to output the next record from the data source range as a row in the table or to end the letter and start the next one. In this way I should end up with one document per Customer, each with a list of their records from the Excel range, like this: However, what I actually end up with is something like this: So is there any way to get this to actually display in a table properly? I have tried moving the closing/terminating double quote at the end of each table row into the final cell on that row, but this breaks the merge entirely, so I cannot see how I can get this to work. Any suggestions would be most welcome! |
#2
|
||||
|
||||
Hi 3N1GM4,
Your mergefield code appears to come from my my Microsoft Word Catalogue/Directory Mailmerge Tutorial at: http://windowssecrets.com/forums/sho...ngs-(2000-2010) or http://www.gmayor.com/Zips/Catalogue%20Mailmerge.zip The tutorial includes a 'TableJoiner' that should be run after the mailmerge to join the tables. The alternative is to format the the mailmerge field coding to insert a paragraph break that is only 1pt high, with no before/after space, as per the 'Calculating Table Totals' example.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Hi macropod,
Thanks very much for the advice, I have been able to run the TableJoiner macro on my merged document, but unfortunately it only seems to remove the gap between the header row of the table and the first row of data - all subsequent rows are still spaced: MacroOutput.PNG What am I missing to get this to join all of the rows correctly? Thanks. |
#4
|
||||
|
||||
Hi 3N1GM4,
That suggests that, before running the macro, there's more than one paragraph break between the tables that are supposed to get joined. That, in turn, suggests you have an extra paragraph break (or a space before a required paragraph break) in/after the mergefield in your mailmerge main document. Fix that and it should work OK.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Quote:
In fact, I cannot find any paragraph breaks in the document around my tables which I can remove without it causing the layout to break completely (it starts to move double quote characters into the actual cells of my tables if I do, which stops the merge from working at all). Is there any particular method or process I can follow to troubleshoot this? My screenshot in my OP shows a representation of how my mailmerge main document is laid out. |
#6
|
||||
|
||||
If you can post a copy of your mailmerge main document and some representative data (nothing sensitive), I'll take a look at it.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Attached is an example data sheet and mail merge document - thanks for having a look at this.
I can see that what you are saying is correct, because prior to running the TableJoiner macro on the merged document, there is only a single linebreak between the header row of each table and the first data row, but there are two between each subsequent pair of data rows - I just can't see how to eradicate this from the mailmerge template document. Thanks again for your help! |
#8
|
||||
|
||||
Hi 3N1GM4,
Your document's field construction differs significantly from that shown in the tutorial. For example, if you set the field code display 'on' and select from the first field brace to the first 'IF', in: • your document, only the first few lines will be selected. • the tutorial document, all of the fields in the document will be selected. I suggest trying again, by copying the relevant field from the tutorial and editing the contents to suit your needs.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
Ok, I will give this another try, thanks.
|
#10
|
|||
|
|||
Fantastic, all working now and I feel like I've learned a little more thoroughly now exactly how MailMerge works! Just have to fiddle with the exact layout and fields now to get the letters looking exactly how we want them.
Thanks so much for your help macropod, appreciate it. |
#11
|
|||
|
|||
Quote:
I know you posted this a few years ago. Im trying to do the same. How did you able to joined the tables? |
#12
|
||||
|
||||
The macro to do that is in the tutorial referred to in the links in post #2
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mail Merge to create specific number of table rows | flackend | Mail Merge | 4 | 12-01-2023 02:49 PM |
Text preceeding a directory merge | entercomp | Mail Merge | 0 | 02-13-2010 08:28 PM |
Insert formatted table into word (mail merge) | manojbmsce | Mail Merge | 0 | 09-25-2008 02:25 AM |
word catalog table layout problem... | turk1130 | Word Tables | 0 | 08-01-2006 11:56 AM |