0 Replies Latest reply on Jan 22, 2016 7:00 AM by SteveP-Integra

    Apply script to table selection only

    SteveP-Integra

      Hi All,

       

      I am using an automated system to mount my data (in tables) on to my catalogue pages.

      I require a way to apply alternating fills which consistently start with the same tint.

       

      I found this handy script on the forum, but I require it to work with the selected rows/columns only rather than the whole table.

       

      app.doScript(function() { 

        // Put Swatch names in here, many as you like: 

        var rowFills = [ 

        //"01 IP CCTV"

          "01 IP CCTV SECONDARY"

        ]; 

        // Put Percentages in here, again many as you like: 

        var rowTints = [ 

        10, 

          25

        ]; 

        table = app.selection[0]; 

        if (table.hasOwnProperty("baseline")) table = table.parent; 

        if (table instanceof Cell) table = table.parent; 

        if (table instanceof Column) table = table.parent; 

        if (table instanceof Row) table = table.parent; 

        if (table instanceof Table) 

        { 

          var startAt = table.headerRowCount; 

          var numRows = table.rows.length-startAt-table.footerRowCount; 

          for (r=1; r<numRows; r++) 

          { 

            table.rows[startAt+r].fillColor = app.activeDocument.swatches.item(rowFills[r % rowFills.length]); 

            table.rows[startAt+r].fillTint = rowTints[r % rowTints.length]; 

          } 

        } else 

        { 

          alert ("Yeah, come to think of it you were actually nowhere near a table, werentya?"); 

          exit(); 

        } 

      }, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Alternate Table Fills");

       

      Thanks in advance!