Skip to main content
Participant
February 8, 2024
Question

Script error in data merge output document

  • February 8, 2024
  • 1 reply
  • 262 views

A script (that I found online) that I use regularly doesn't work in a document resulting from a data merge. The script works perfectly in any other regular document. 

 

This is the script, to automatically delete all rows with a specific text ("*"):

var allStories = app.documents[0].stories;

var st = 0;

while(st < allStories.length){

    var allTables = allStories[st].tables;

    var tbl = 0;

    while(tbl < allTables.length){

        var allCells = allTables[tbl].cells;

        var cel = 0;

        while(cel < allCells.length){

            if(allCells[cel].contents.toString().toLowerCase().indexOf("*") != -1){

                allCells[cel].rows[0].remove();

                allCells =  allTables[tbl].cells;

                cel = -1;

                }

            cel++;

            }

        tbl++;

        }

    st++;

    }

 

And this is the error I get when running it on a data merged document:

 

 

Any one know why it's only happening on data merged documents? 

This topic has been closed for replies.

1 reply

vimkoAuthor
Participant
February 8, 2024
danaken3
Participating Frequently
February 10, 2024

Could you share a sample .indd file where the script isn't working?