PDA

View Full Version : [SOLVED:] Insert new rows with mail merge fields



framcc06
05-16-2018, 11:37 AM
Hi Folks,

Currently, I have a mail merge document, that when closing runs a macro which deletes the empty rows at the bottom of the table (the merge fields are in the table ex-header row), saves the document as pdf in a folder then prompts me whether to save which I select no.

Can anyone provide a macro which adds rows to the bottom of the table with the mail merge fields included (preferably so the table will always have 30 rows) so I could run the macro on the before save event.

Thanks,

Fra

macropod
05-16-2018, 04:43 PM
Your current approach suggests you're approaching the issue the wrong way; it should be possible for a mailmerge to generate only the rows that are needed as it is executed.

As for adding table rows with mergefields, that's possible, but would require knowing in advance what those mergefields are and how each cell is to be formatted. Morevover, it's not apparent why you'd want to do this.

framcc06
05-16-2018, 10:57 PM
Thanks Paul for your quick reply, I was trying to figure out how to get the table back to the original size after deleting the empty rows and saving as pdf without having to close and open again constantly.

Can you provide sample code or link to generate mail merge with rows that are needed as that sounds like the best solution.

Fra

macropod
05-16-2018, 11:17 PM
How that is done depends on how your Word table and the source data are structured. Without knowing both those things, it's impossible to give specific advice. Can you attach your mailmerge main document and a sample data file to a post with some representative content (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.

framcc06
05-19-2018, 12:27 AM
Thanks Paul, the tutorial you provided on the windowssecrets forum is what i need.

Regards,

Fra