Skip to main content
December 16, 2017
해결됨

Looking for a script to add one row at the end of a table, merge it and add text

  • December 16, 2017
  • 1 답변
  • 2833 조회

Hi all,

My client decided they want to add a row at the end of all the tables with a note. I figured out how to add the row using the script below, but cannot figure out how to merge that row and then add in the new copy. Currently the tables are one row, three columns. The new row should be merged across all the columns (see example below). Can anyone tell me if this is even possible to script? I have tons of documents I have to do this on so any help would be greatly appreciated!

var curDoc = app.activeDocument;

var allTables = curDoc.stories.everyItem().tables.everyItem().getElements();

for ( var t = 0; t < allTables.length; t++ ) {

    var curTable = allTables;

    var allRows = curTable.rows;

curTable.rows.add(LocationOptions.AT_END);

}

이 주제는 답변이 닫혔습니다.
최고의 답변: lfcorullon13651490

I'm not on my PC now, but I would try something like:

var curDoc = app.activeDocument;

var allTables = curDoc.stories.everyItem().tables.everyItem().getElements();

for ( var t = 0; t < allTables.length; t++ ) {

var curTable = allTables;

var allRows = curTable.rows;

var newRow = curTable.rows.add(LocationOptions.AT_END);

newRow.cells.everyItem().merge();

}

>

1 답변

lfcorullon13651490
Legend
December 16, 2017

I'm not on my PC now, but I would try something like:

var curDoc = app.activeDocument;

var allTables = curDoc.stories.everyItem().tables.everyItem().getElements();

for ( var t = 0; t < allTables.length; t++ ) {

var curTable = allTables;

var allRows = curTable.rows;

var newRow = curTable.rows.add(LocationOptions.AT_END);

newRow.cells.everyItem().merge();

}

>

Obi-wan Kenobi
Legend
December 16, 2017

Corullon,

Next time, turn on your machine! …

newRow.cells[0].merge (newRow.cells[-1]);

(^/)

December 16, 2017

That worked, thank you both! Is there a way to add this copy to that row as well?

Note: If the student responds incorrectly, proceed to the next set of DO and SAY statements below.