2 Replies Latest reply on Jan 26, 2017 9:59 AM by Laubender

    How to set cell options > keep options > start row to 'anywhere' via jsx script




      do anyone know how to do?

      I found only dialog box answers with manual stetting.


      startRow = StartParagraph.anywhere;


      seems to be not the right way.

      I want to set this to all body cells in different tables.

      Oh, I am a absolute beginner in scripting.


      Thank you for answering

        • 1. Re: How to set cell options > keep options > start row to 'anywhere' via jsx script
          vkf1v99129099 Level 1

          Found a solution:


          var myDocument = app.documents.item(0);

          var myTable = myDocument.stories.item(0).tables.item(0);

          myTable.cells.everyItem().properties = {startRow:StartParagraph.ANYWHERE};


          It's very basic.

          Check first that document open and table selected.


          If you want to apply this to all body cells, you can do this with a menu action.




          // Table -> Select -> Body Rows

          app.menuActions.item("$ID/Body Rows").invoke();



          Happy scripting :-)

          • 2. Re: How to set cell options > keep options > start row to 'anywhere' via jsx script
            Laubender Adobe Community Professional & MVP


            there are two properties for tables that reflect the number of rows for header rows and footer rows:

            headerRowCount and footerRowCount


            If there are header rows their index numbers in the array of rows are always starting with 0: 0,1,2 …

            If there are footer rows their index numbers are always starting from the end of the index numbers in the collection -1, -2, -3 you are doing with everyItem() of rows.


            Since we also have information about the number of the body rows with property bodyRowCount of a table, it's sufficient to know the number of header rows to access the header rows by their number with a loop.


            So you need not to work with menuActions on selections to do things with body rows only.


            Example where we start the loop through all rows after the header rows below.
            Also note that not only cells, but also rows have the property startRow that can be used here.
            No need to access the cells directly:


            var doc = app.documents[0];
            // First table in the collection of stories in creation order of stories:
            var table = doc.stories.everyItem().tables.everyItem().getElements()[0];
            var numberOfHeaderRows = table.headerRowCount;
            var numberOfBodyRows = table.bodyRowCount;
            var rowsOfTable = table.rows.everyItem().getElements();
            // Loop through all body rows:
            for(var n=numberOfHeaderRows; n<numberOfHeaderRows + numberOfBodyRows; n++)
                rowsOfTable[n].startRow = StartParagraph.ANYWHERE ;


            Oh. And I really like your creative workaround using menuActions for doing what you want.

            When the time comes this knowledge is important to do things the DOM does not provide.
            But sometimes its also counter-productive or not possible at all to use like with InDesign Server that has no UI.