Another Data Merge script: Data merge to batches

This latest script compensates for a feature that should be available in InDesign’s Data Merge feature, but simply doesn’t work.

The problem:

Take for example the following Data Merge file where we want to export a custom range, but prepare PDFs in batches of 50s for production purposes. Each record is one page long.


When the Data Merge feature is used in Adobe InDesign, it is possible to merge to several new InDesign files that contain a maximum amount of records per file. The same dialog box is present when merging directly to PDF as well.


Unfortunately, the Record Limit per Document checkbox may as well be there for decoration, because it doesn’t work. Instead of 13 PDFs being created with the maximum size of each PDF being 50 records long, a PDF the size of the complete merge file is created.


The workaround

It is possible to split the document into ranges 50 pages per PDF, but it has to be done in Acrobat. From here, click the Organize Pages button.


This will show the Organize Pages toolbar.


From here, click on the split icon to show the split pages portion of the toolbar.


With the split pages toolbar now visible, choose the appropriate split by dropdown and edit the amount required. In this case, we need “number of pages” and 50 pages.


The files now need to be saved somewhere. Click the Output Options button to show the Output Options dialog.


Select a destination for the files and any additional filenaming information and click OK.


Once back at the regular toolbar, click the big blue split button.


The task will run and then present a dialog box once it is complete.


On an example such as the one demonstrated, this isn’t an onerous task. However, if working in a production setting where PDF page lengths can be tens of thousands or longer, this is inconvenient and unacceptable.

The solution

Rather than use the Adobe Acrobat solution, I would prefer that the original dialog box worked correctly. One option is to let the Adobe InDesign Engineers know that it should be fixed. A link to the direct request can be found here.

Until it is fixed, I’ve written a free script specifically for this purpose.


Using the earlier example, the same settings will be keyed in.


Once keyed in, click OK. A progress bar will let you know how the merge is going.


An alert will let you know when the merge is complete. The files are then saved to the selected destination with no extra splitting required.


Interested in this script? It can be downloaded from here.


  1. This script sounds like just what I need, but when I run if I get the error:

    Javascipt error!

    Error Number 107018
    Error String: One or more of the records specified are not valid record numbers.

    Can you help at all please?


  2. I got 2 errors when using this script on Windows 10 Pro.

    (A) Error Number:45 String: “Object is invalid” on line 91 when run on InDesign Chinese version, but change language to English (en_US) is working fine.
    (B) Error Number:107018 String: “One or more of the records specified are not valid record numbers” at line 375 on English version of CC and CS6.

    Is there any chance to fix ? I guess some variables are language dependent in the script.

    • About the error 107018, There is an issue with the script that involves the last line in the database being blank. Make sure the last line in the database is on a record and not an empty row, and see if this works. About this error that occurs in the Chinese UI, I will investigate this, thank you for letting me know

  3. Thanks for the quick response. The work around solves error 107018 and works great. By the way, my UI language is zh_TW in InDesign CC. Thanks in advance.

  4. Good morning. Script works perfectly. However, it does not support Multiple Up records. (or I am not smart enough to find this feature in your script). I used to use Creo Darwin for variable data, which piggy backed on InDesign and this feature worked perfectly. I am not sure why Adobe cannot get it to work in their own application!

This site uses Akismet to reduce spam. Learn how your comment data is processed.