5 Replies Latest reply on Nov 2, 2018 5:10 AM by BarlaeDC

    Assign cell style to empty table cells + clear cell style overrides

    mikefwd Level 1

      I’m data merging into a table which will create a multi page document with some empty cells.

       

      I’m trying to write a script that applies a cell style to empty cells and then clears cells style overrides for empty cells as well.

       

      So far I’ve written the following (where 'EmptyCell' is the cell style I want to apply to all empty cells):

       

      var myDocument = app.documents.item(0);

      var myTable = myDocument.stories.item(0).tables.item(0);

       

      for(var i = 0; i < myTable.cells.length; i++) {

        if (myTable.cells[i].contents === '') {

          myTable.cells[i].appliedCellStyle = 'EmptyCell';

        }

      }

      for(var i = 0; i < myTable.cells.length; i++) {

        if (myTable.cells[i].contents === '') {

          myTable.cells[i].clearCellStyleOverrides();

        }

      }

       

      This does what I want it to do, but only to the first table in the multi page document.

       

      What do I need to do to make this cell work for all tables in the multi page document??

       

      I’m a total beginner at scripting so any help would be much appreciated.

       

      Cheers

       

      Mike