Mail Merge - Output in Separate Files with Different Filenames RRS feed

  • Question

  • Dear all

    Previously, I was able to utilise a macro which helped me with a mail merge. The macro would mail merge the files out (as pdf) into a specific directory and rename the files based on the relevant filename provided in source spreadsheet.

    Unfortunately, the company has since upgraded to Office 365 and disabled all macros (trusted / signed etc.) :'( I now don't have this tool to help me.

    Is there a batch script or vbs script or Powershell script that I might be able to cobble together to help me with this task? I am doing things manually but have already picked up on a few errors and I dread to think how I would manage once I have to mail merge 500+ documents ...

    Thanks in advance!


    Wednesday, February 26, 2020 1:17 AM

All replies

  • Hi Nic,

    Thanks for visiting our forum. Our forum focuses on Microsoft Teams, which is the hub for team collaboration in Office 365. 

    Based on your description, this problem seems related to Microsoft Office for Developers, I will move this case to this forum( ). Hope you get better response.

    Thanks for your understanding. 

    Best Regards,
    Sharon Zhao

    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact

    Wednesday, February 26, 2020 5:15 AM
  • See 'Send Mailmerge Output to Individual Files' in the Mailmerge Tips and Tricks thread at:

    Paul Edstein
    [MS MVP - Word]

    Wednesday, February 26, 2020 10:46 AM
  • Thanks for the response Paul - unfortunately, that was *the* macro solution I was using up until now. The company has since disabled macros through the group policy and we don't have any authorization to run macros now. Hence looking at other ways to do this task.

    Thursday, February 27, 2020 12:22 AM
  • Based on your description, this problem seems related to Microsoft Office for Developers, I will move this case to this forum
    Thanks for moving it to the right place!
    Thursday, February 27, 2020 12:23 AM
  • 1. Have you tried converting the VBA code Paul referenced to VBS? There are some bits of VBA that won't port, e.g. all variables are Dim'd as Objects, but you may find that most of it works without much change.

    2. Do all your mailmerges produce one PDF for each record in the data source (or for a fixed number of records in the data source) or does each PDF consume a variable number of data source records?

    Peter Jamieson

    Thursday, February 27, 2020 9:09 AM
  • If macros have been disabled, you'll have a bigger challenge doing this via vbs, etc., as whichever other approach you take will have to both automate Word and disable the mailmerge SQL prompt, which means you'll also have to reconfigure the document as a mailmerge main document, connect to the data source and supply the SQL arguments - all using late binding. The link I supplied has an Excel macro that shows what would be needed, but using early binding.

    Paul Edstein
    [MS MVP - Word]

    Thursday, February 27, 2020 11:22 AM