4 Replies Latest reply on Mar 19, 2017 5:18 AM by Raphaël Freeman

    apply cell style and overrides

    Raphaël Freeman

      I have written a very simple script with the help of Peter Kahrel’s book to make all the rows of a table the height of 11 and the first and last cell in the first column a certain cell style.

       

      It works, but when applying the cell style, I need it to override the local formatting. How do I do that?

       

      var myDoc = app.activeDocument;

      var myTable = get_table();

      myTable.rows[0].cells[0].appliedCellStyle="anaf alef";

      myTable.rows[-1].cells[0].appliedCellStyle="anaf bet";

      for (var i = 0; i<myTable.rows.length; i=i+1)

      {

          myTable.rows[i].textTopInset = "1";

          myTable.rows[i].textBottomInset = "1";

          myTable.rows[i].height="11";

      }

       

      function get_table ()

          {

          if (app.selection.length > 0) // proceed only if something is selected

              {

              var mySelection = app.selection[0];

              if (mySelection.parent.constructor.name == "Table")

                          return mySelection.parent;

              else if (mySelection.parent.parent.constructor.name == "Table")

                          return mySelection.parent.parent;

                 }

          alert ("Cursor not in a table\ror illegal selection.");

          exit ();

      }