Consulting

Results 1 to 5 of 5

Thread: Insert new rows with mail merge fields

  1. #1
    VBAX Regular
    Joined
    Sep 2017
    Posts
    11
    Location

    Insert new rows with mail merge fields

    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

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    3,585
    Location
    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.
    Cheers
    Paul Edstein
    [MS MVP - Word]

  3. #3
    VBAX Regular
    Joined
    Sep 2017
    Posts
    11
    Location
    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

  4. #4
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    3,585
    Location
    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.
    Cheers
    Paul Edstein
    [MS MVP - Word]

  5. #5
    VBAX Regular
    Joined
    Sep 2017
    Posts
    11
    Location
    Thanks Paul, the tutorial you provided on the windowssecrets forum is what i need.

    Regards,

    Fra

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •