1 Reply Latest reply on Jun 18, 2012 2:36 PM by crayz77

    Add columns to existing table

    crayz77

      I am trying to calculate how many columns in an existing tables, then add more columns to the tables until they reached 20.

      Now the script I have written works fine when the cells of the tables are empty, but as soon the cells have text(data) in them the scipt errors, any ideas why?

       

       

       

      var myTable = 0;

      var tableNum = 0;

       

       

      convertTables()

       

       

      //select table

      function convertTables() {

      if (app.documents.length > 0 && app.selection.length > 0)

          myTable = app.select(app.activeDocument.pages[0].textFrames[0].tables[tableNum]);

         

      addColumn ()

       

       

      }

       

       

      //add columns to table

      function addColumn() {

       

       

      myTable = app.selection[0];

         

      var number =  myTable.columnCount;

         

      if (number < 20) {

            myTable.columns.add(LocationOptions.atEnd,myTable);

            addColumn();

      }

      else

      {

      convertTables();

          }

      }