#1
|
|||
|
|||
Merging multiple items to a table, Formatting
Hello Everyone!
Looking for some help with the formatting structure of letter using mail merge of multiple rows to a table I am using the following table created by Paul Edstein, for another user over at windowsecrets: https://forums.windowssecrets.com/sh...ussions/page11 This table fits my needs. However, I am having problems with the formatting of the letter and the table itself I am inserting the body of the letter between "SET Key { MERGEFIELD Source_Supplier }} AND the beginning of the actual table (Results are OK, except that the 1st record or merge has an extra line space at the top, this is not a problem, I'm simply "reporting")(I did insert a single merge field at the very top) The formatting problems I have: 1: How can I force the table to have no spaces between the table headers and the rows below ? 2: Also, no spaces between rows (I will have up to 8 rows merged and need the space in the letter) 3: How to force a break to start a new record after the table is completed ? (The data is sorted by Source_Supplier) When the Source supplier changes, a new document should start (I believed I solved this one by using the "QUOTE 12" code and combining it with what you had done) 4: Is it possible to merge a 2 page document (2 languages) side by side (I tried and only the 1st record worked, then only the 1st page would be merged, skipping the 2nd page) (This is not a big deal but it would be nice... I can run the merge 2 times, individually and use the resulting 2 files with merged records) Thank you all for your time and your valued contributions Last edited by orion23; 07-19-2018 at 11:57 AM. |
#2
|
||||
|
||||
As indicated in the link from which you got the field coding, the document was part of a larger project that executes a macro upon completion of the merge. Amongst other things, that macro removes the empty paragraphs between the tables.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
TBH, I liked the simple table layout and I modified it to be used in my current task
I took the table idea and merged it with this: {QUOTE{IF{MERGESEQ} = 1 {SET Key ""}{SET LastKey {Key}}}{If{MERGEFIELD id} <> {Key} "{IF{MERGESEQ} > 1" {IF{MERGEFIELD id} <> 0 {QUOTE 12}}""}{IF{MERGEFIELD id} <> 0 "(this is the body of my letter {SET KEY {MERGEFIELD id}} id: {MERGEFIELD id\* Charformat} (this is where I inserted your table) "}"}"{IF{MERGEFIELD id} <> 0 "{MERGEFIELD date} / {MERGEFIELD time} {MERGEFIELD location} "}"} What I have is a letter with a 3 column table where 3 fields are merged in a list form Everything looks great and works fine at this time, however, I'm afraid that I won't have much room left in the body of the letter since every entry in the list leaves me with an empty space in between each row. The records I will merge can be up to a total of 8, and with the extra blank row, I'm looking at too much wasted space Do you know how I can solve that part ? (I'll try uploading that latest version of the file tomorrow...) and if possible, could you confirm if a directory type of merge can be used in a 2 page document (same mergefields, table, just 2 different languages, side by side) Also, the result needs to be a single word document with all individual records, separated by page, which is what I have. The only concern at this time really is the extra rows (and possibly the 2 page merge but that can be resolved with an additional, separate merge) Thanks again for your time! |
#4
|
||||
|
||||
Please read 'Merging to Tables' in my Microsoft Word Catalogue/Directory Mailmerge Tutorial:
https://www.msofficeforums.com/mail-...-tutorial.html
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
So I need to run this Macro ?
Code:
Sub TableJoiner() Application.ScreenUpdating = False Dim oPara As Paragraph For Each oPara In ActiveDocument.Paragraphs With oPara.Range If .Information(wdWithInTable) = True Then With .Next If .Information(wdWithInTable) = False Then If .Text = vbCr Then .Delete End If End With End If End With Next Application.ScreenUpdating = True End Sub My fear is that by removing the rows after the merge, all records will shift up and won't remain as individual records If you think of something else that I might be missing, kindly point it out Thanks for your help! Last edited by macropod; 07-19-2018 at 09:52 PM. Reason: Added code tags |
#6
|
||||
|
||||
Yes. FWIW, if you:
1. save it in your mailmerge main document (which means using the .doc or .docm format) 2. rename the macro to MailMergeToDoc 3. insert the line: ThisDocument.MailMerge.Execute Pause:=False after: Dim oPara As Paragraph the macro will run automatically when you click on the 'Edit Individual Documents' button. PS: When posting code, please use the code tags, indicated by the # button on the posting menu. Without them, your code loses much of whatever structure it had.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Good morning*
Just tried the original macro and it pauses to process for about 3 seconds but nothing happens (No errors) I also tried as you suggested (rename + ThisDocument.MailMerge.Execute Pause:=False) but a receive the following error when I click on "Finish & Merge" "Edit individual documents" This method or property is not available because the document is not a mail merge main document Any ideas ? Honestly, I don't have to use a table, but it helps me with the alignment of the merged data, which I cannot align otherwise (I've tried...) If you could, can I ask you to please help me alight the column headers (Date, Time and Location) with the corresponding mergefields just below ? Date and time vary in lenght Thanks for your help! |
#8
|
|||
|
|||
I believe I finally understand the alignment part
(will confirm once back in the office) |
#9
|
||||
|
||||
That suggests you added it to something other than your mailmerge main document...
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Pivot Table: Show Data For Multiple Items | jhato160 | Excel | 14 | 08-01-2016 11:24 AM |
VBA Pivot Table CubeField Enable multiple items | Wries | Excel Programming | 0 | 03-13-2014 09:56 AM |
After merging a reviewer's changes, formatting is lost | cassidyjames | Word | 0 | 03-27-2012 01:48 PM |
Copy table cell formatting across multiple cells / tables | pakistanray | Word Tables | 2 | 10-31-2011 08:07 AM |
Merging multiple .txt's | Bartestokles | Word | 5 | 12-29-2010 01:42 PM |