Skip to main content
Inspiring
August 9, 2019
Answered

How to define the cells at last column

  • August 9, 2019
  • 1 reply
  • 480 views

Hi experts,

my script like this:

var docs = app.documents;

    for (var i = docs.length-1; i >= 0; i--) {

            var myCells = docs.stories.everyItem().tables.everyItem().cells.everyItem().getElements(); 

            for(var n = 0; n < myCells.length; n++) 

            { 

                var mCellStyles = docs.allCellStyles;

                    if (/^9[9876]/.test (myCells.appliedCellStyle.name)) { 

                            myCells.contents = " "; 

                            var myRow = myCells.parent.rows;

                                    myRow.cells[-1].rightInset ="2 mm";

                      } 

                } 

            }

aim to let last column of cells if the cell applied cell style 96 97 98 99, rightInset ="2 mm";

but not working,

could someone please show me how.

thanks

regard

John

This topic has been closed for replies.
Correct answer Sunil Yadav

Try this:

var docs = app.documents;

for (var i = docs.length-1; i >= 0; i--) {

    var myCells = docs.stories.everyItem().tables.everyItem().columns[-1].cells.everyItem().getElements();

    for(var n = 0; n < myCells.length; n++){

        if (/^9[9876]/.test (myCells.appliedCellStyle.name)) {

            myCells.contents = " ";

            var mycolumn = myCells.columns[0];

            mycolumn.cells.everyItem().rightInset ="2 mm";

            }

        }

    }

Best

Sunil

1 reply

Sunil Yadav
Sunil YadavCorrect answer
Legend
August 10, 2019

Try this:

var docs = app.documents;

for (var i = docs.length-1; i >= 0; i--) {

    var myCells = docs.stories.everyItem().tables.everyItem().columns[-1].cells.everyItem().getElements();

    for(var n = 0; n < myCells.length; n++){

        if (/^9[9876]/.test (myCells.appliedCellStyle.name)) {

            myCells.contents = " ";

            var mycolumn = myCells.columns[0];

            mycolumn.cells.everyItem().rightInset ="2 mm";

            }

        }

    }

Best

Sunil

JohnwhiteAuthor
Inspiring
August 10, 2019

thank you Sunil

thank so much

John