3 Replies Latest reply on Sep 25, 2012 11:31 AM by -hans-

    Table format

    Frillo@Adobe Level 1

      Hi,

      I tried to figure out how to auto format a table; googling around I did a patchwork of script snippets and eventually I came to this:

       

      app.activeDocument.stories.everyItem().tables.everyItem().rows.everyItem().properties = {autoGrow:false};

      var doc = app.activeDocument;

       

       

      var everyStory = doc.stories.everyItem();

      var everyTable = everyStory.tables.everyItem();

      var allRows = everyTable.rows.everyItem().getElements();

       

       

      for (var i=1, l=allRows.length; i < l; i++) {

         var row = allRows[i];

         row.height = "2 cm";

         row.width = "2 cm";

      };

       

      Now, this works fine but it seems to affect every row EXCEPT the first one. I have to stress out thatin my table there is no Header row at all.

      How is this?

      Thank you,

        • 1. Re: Table format
          -hans- Level 4

          Hi,

           

          JS starts counting 0.

           

          You may shorten it:

           

          var allRows = app.activeDocument.stories.everyItem().tables.everyItem().rows.everyItem().getElements();
          l = allRows.length;
          
          for (var i = 0; i <  l; i++) {
             with(allRows[i]){
          //set all rowProperties here
             height = "2 cm";
             width = "2 cm";
             autoGrow = false;
          }
          };
          
          • 2. Re: Table format
            Frillo@Adobe Level 1

            This is embarassing...

            Thank you, hans

            g

             

            Il giorno 25/set/2012, alle ore 20:23, -hans- <forums@adobe.com> ha scritto:

             

            var allRows = app.activeDocument.stories.everyItem().tables.everyItem().rows.everyItem().getElements();

            l = allRows.length;

             

            for (var i = 0; i <  l; i++) {

               with(allRows[i]){

            //set all rowProperties here

               height = "2 cm";

               width = "2 cm";

               autoGrow = false;

            }

            };

             

            • 3. Re: Table format
              -hans- Level 4

              or without loop:

               

              with(app.activeDocument.stories.everyItem().tables.everyItem().rows.everyItem()){
                  autoGrow:false;
                height = "2 cm";
                  width = "2 cm";
                 }