3 Replies Latest reply on Jun 11, 2014 5:28 AM by cja17

    How to set column widths in tables for selected table only, not globally throughout document?

    aprilrosesrq

      I've been utilizing the below script (thank you so much Ramkumar. P!) to set column widths throughout a sizable InDesign book with tables on every page and it is truly a time saver. At this point in time, I have three versions of it because there are different column widths throughout the book. Is it possible to augment the script to run only on a selected text frame (containing a table)? If so, would someone be kind enough to share the augmented script with me? I've been trying to figure out this seemingly simple change through trial and error with no success as yet. I realize this is a totally newbie request and I'm entirely at the mercy of the kindness of the Javascript gods that contribute within this forum. Seeing that in a different post related to this script, one such guru responded to a request as simple as "Where do I put the scripts in InDesign" gave me enough courage to ask for some help! Thank you in advance to anyone willing to provide a solution.

       

       

        var myDoc = app.activeDocument;

           var myWidths = [100, 100, 150, 150];

           for(var T=0; T < myDoc.textFrames.length; T++){

               for(var i=0; i < myDoc.textFrames[T].tables.length; i++){

                   for(var j=0; j < myWidths.length; j++){

                       myDoc.textFrames[T].tables[i].columns[j].width = myWidths[j];

                   }

               }

           }

           alert("Table width updated successfully...");