ExtendScript, InDesign 2022: Return `parentPage`s of last cells of all tables
I’m trying to bring this function alive:
$.writeln( findPagesOfLastCells() );
function findPagesOfLastCells() {
// https://community.adobe.com/t5/indesign-discussions/javascript-property-to-tell-if-text-is-in-a-continued-table/td-p/6379093
var aDoc = app.activeDocument,
allTables = aDoc.stories.everyItem().tables,
thePages = [];
if( allTables.length > 0 ) {
for ( var i = 0; i < allTables.length; i++ ) {
var theTable = allTables[i];
$.writeln('***********tables************\n'+theTable);
if ( theTable.rows.length > 1 ) {
var lastRowPage = 0;
lastRowPage = theTable.rows[-1].cells[-1].insertionPoints[-1].parentTextFrames[0].parentPage;
$.writeln(lastRowPage);
thePages.push(lastRowPage.name);
$.writeln(lastRowPage.name);
}
}
}
return thePages;
}
The crucial parts is here:
lastRowPage = theTable.rows[-1].cells[-1].insertionPoints[-1].parentTextFrames[0].parentPage;This doesn’t work and results to undefined. It works fine with this:
theTable.rows[-1].cells[-1].insertionPoints[-1]I get an insertion point with all properties, including a parentTextFrames property. But extending to
theTable.rows[-1].cells[-1].insertionPoints[-1].parentTextFrames[0]I get a text frame reference with no property at all.
Is this a bug? Am I doing something wrong?
Thanks for your kind help,
Tobias

