Copy link to clipboard
Copied
Hello everybody.
It is really a simple thing. And for me it makes sense like I wrote that script. Unfortunatly: it does not work . Where is my error in reasoning?
...
if (myTables.rows.firstItem().rowType == RowTypes.BODY_ROW) {
myTables.rows[0].rowType = RowTypes.HEADER_ROW; )
}
if (myTables.rows[-1].rowType == RowTypes.BODY_ROW) {
myTables.rows[-1].rowType = RowTypes.FOOTER_ROW;
}
...
Nothing will be detected betweeen the parantheses. --> The condition has no function. There is no error-message too.
Copy link to clipboard
Copied
I see only one problem in your code: the line 2 has a closing round bracket at the end.
Otherwise it works for me on my InDesign CC 2015 for Mac.
main();
function main() {
var myTables = app.selection[0]; // Let's assume a table is selected
if (myTables.rows[0].rowType == RowTypes.BODY_ROW) {
myTables.rows[0].rowType = RowTypes.HEADER_ROW;
}
if (myTables.rows[-1].rowType == RowTypes.BODY_ROW) {
myTables.rows[-1].rowType = RowTypes.FOOTER_ROW;
}
}
Also, I recommend you to use rows[0] instead of rows.firstItem() because it's faster.
— Kas
Copy link to clipboard
Copied
If you have a cell selected then the following code works
myTables = app.selection[0].parent;
if (myTables.rows[0].rowType == RowTypes.BODY_ROW) {
myTables.rows[0].rowType = RowTypes.HEADER_ROW;
}
if (myTables.rows[-1].rowType == RowTypes.BODY_ROW) {
myTables.rows[-1].rowType = RowTypes.FOOTER_ROW;
}
Check that your "myTables" is really a table, alert(myTables)
Find more inspiration, events, and resources on the new Adobe Community
Explore Now