6 Replies Latest reply on Aug 30, 2012 12:41 PM by lazycarpenter

    Tables - Row Height and Cell Insets

    lazycarpenter Level 1

      I am working on ascript to do the following:

       

      1. Set the first Row of all tables in my doc to these settings:

      • Row Height = .25in
      • Top and Bottom Inset = .04in

       

      2. Set rest of the cells to these settings:

      • Row Height = .12in
      • Top and Bottom Inset = .12in

       

      Here is where I am at:

       

       

      app.activeDocument.stories.everyItem().tables.everyItem().rows[0].height = ".25 in";

      app.activeDocument.stories.everyItem().tables.everyItem().rows[0].topInset = ".04 in";

      app.activeDocument.stories.everyItem().tables.everyItem().rows[0].bottomInset = ".04 in";

       

       

      for( x = 1; x < app.activeDocument.stories.everyItem().tables.everyItem().rows.length; x++ ) {

      app.activeDocument.stories.everyItem().tables.everyItem().rows[x].height = ".12 in";

      }

       

       

      for( x = 1; x < app.activeDocument.stories.everyItem().tables.everyItem().rows.topInset; x++ ) {

      app.activeDocument.stories.everyItem().tables.everyItem().rows[x].topInset = ".12 in";

      }

       

       

      for( x = 1; x < app.activeDocument.stories.everyItem().tables.everyItem().rows.bottomInset; x++ ) {

      app.activeDocument.stories.everyItem().tables.everyItem().rows[x].bottomInset = ".12 in";

      }

       

       

       

      I keep getting this error and I am stuck.

       

      error-1.jpg

       

      Anyone see anything that would help?

       

      Thanks in advance.

        • 1. Re: Tables - Row Height and Cell Insets
          [Jongware] Most Valuable Participant

          There is indeed an extra closing parentheses on that line in the screenshot (but not in your sample lines).

           

          I wonder if this construction

           

          for( x = 1; x < app.activeDocument.stories.everyItem().tables.everyItem().rows.length ; x++ ) {
          app.activeDocument.stories.everyItem().tables.everyItem().rows[x].heig ht = ".12 in";
          }
          

           

          every could work ... The for..loop expects a simple end number, but you feed it with an array of all of your individual tables' row lengths.

           

          If this indeed does not work, turn your script around. Set all of the row heights and insets using

           

          app.activeDocument.stories.everyItem().tables.everyItem().rows.everyItem().topInset = ".12 in";

           

          and after that run the lines to do the top row adjustments.

           

          (Use "Advanced editor" to be able to set Javascript syntax highlighting -- it makes your code ever so slightly more readable.)

          • 2. Re: Tables - Row Height and Cell Insets
            lazycarpenter Level 1

            Good ideas. I will give these a shot.

             

            Thanks so much!

            • 3. Re: Tables - Row Height and Cell Insets
              Larry G. Schneider Adobe Community Professional & MVP

              Excuse me but I'm having a hard time understanding where things are going to go in these cells. With a top and bottom inset the same size as the height, it doesn't seem to leave much room for the text.

              • 4. Re: Tables - Row Height and Cell Insets
                lazycarpenter Level 1

                Ahh... Good catch. Forgive me.

                 

                Let me start again with my goals:

                 

                1. Set the first Row of all tables in my doc to these settings:

                • Row Height = .25in
                • Top and Bottom Inset = .04in

                2. Set rest of the cells to these settings:

                • Row Height = .12in
                • Top and Bottom Inset = .012in
                • 5. Re: Tables - Row Height and Cell Insets
                  Larry G. Schneider Adobe Community Professional & MVP

                  I think Jongware has it right. Set the whole table first and then adjust the first row.

                  1 person found this helpful
                  • 6. Re: Tables - Row Height and Cell Insets
                    lazycarpenter Level 1

                    That's it. So simple. Thank you so much for your help.

                     

                     

                    app.activeDocument.stories.everyItem().tables.everyItem().rows.everyItem().height = ".12 in";

                    app.activeDocument.stories.everyItem().tables.everyItem().rows.everyItem().topInset = ".012 in";

                    app.activeDocument.stories.everyItem().tables.everyItem().rows.everyItem().bottomInset = ".012 in";

                     

                     

                    app.activeDocument.stories.everyItem().tables.everyItem().rows[0].height = ".25 in";

                    app.activeDocument.stories.everyItem().tables.everyItem().rows[0].topInset = ".04 in";

                    app.activeDocument.stories.everyItem().tables.everyItem().rows[0].bottomInset = ".04 in";