5 Replies Latest reply on May 25, 2015 12:16 AM by BSKTCreation

    How to find Tables, Table Color/Stroke

    VarunParashar31

      Hi

       

      I have a document that has a lot of tables in it. I need to search tables which has a particular stroke size in any of the cells. Can we find that? and can we change the stroke sizes? Do we have any script for that?

       

      Thanks a lot in advance!

      Varun

        • 1. Re: How to find Tables, Table Color/Stroke
          BSKTCreation Level 2

          Hi Varun,

           

          Try this.

           

          var myStrokeWeightToFind = 1; // Change this to the thickness your looking for
          
          
          var myTables = app.documents[0].stories.everyItem().tables.everyItem().getElements();
          for(var i = 0; i < myTables.length; i++) {
              var myCells = myTables[i].cells;
              for (var j = 0; j < myCells.length; j ++) {
                  if (myCells[j].topEdgeStrokeWeight === myStrokeWeightToFind ||
                  myCells[j].leftEdgeStrokeWeight === myStrokeWeightToFind ||
                  myCells[j].bottomEdgeStrokeWeight === myStrokeWeightToFind ||
                  myCells[j].rightEdgeStrokeWeight === myStrokeWeightToFind) {
                      $.writeln("Found stroke in table " + i + ", cell " + j)
                      }
                  }
              }
          
          
          

           

          Brett

          • 2. Re: How to find Tables, Table Color/Stroke
            VarunParashar31 Level 1

            Thanks Brett for your response!!

             

            But it didn't help, .

             

            I am new to scripting, and just saved it as .jsx file with the help of ExtendScript. But i didn't get any response when i try it in InDesign. Do I need to follow any other steps?

             

            Regards,

            Varun

            • 3. Re: How to find Tables, Table Color/Stroke
              BSKTCreation Level 2

              Ah, I only gave you the bare minimum to get going, sorry about that.

               

              Do you know how to use the ExtendScript Toolkit?

              • 4. Re: How to find Tables, Table Color/Stroke
                VarunParashar31 Level 1

                I know how to handle the software.. not the scripting part

                • 5. Re: How to find Tables, Table Color/Stroke
                  BSKTCreation Level 2


                  No worries.

                   

                  To use the script you'll need to open the Adobe ExtendScript Toolkit, create a new JavaScript (Ctrl+n), copy the code above and paste it into the new file.

                   

                  In InDesign open your document with the tables in it and go back to the JavaScript, change the number in the first line to the thickness of the line you're looking for (generally this is in points) and press F5 to run the script. In the JavaScript Console window a list of outputs will display with the tables and cells that have the matching stroke weight.

                   

                  This script is only telling you the table and cell that have the stroke but not actually doing anything, i.e. it's not making a change when it sees the condition.

                   

                  I hope this makes sense and gives you enough detail to try out some things. For a good introduction in InDesign scripting I recommend reading the following: http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/indesign/sdk/cs6/scripting/InDesign _ScriptingGuide_JS.pdf

                   

                   

                  Regards,

                  Brett

                   

                  Edit: sorry forgot to mention, in ExtendScript change the app it's pointing to from ExtendScript Toolkit to InDesign or the script will crash. You can find this in the drop box at the top of the new JavaScript window.