Legend
December 26, 2024
Question
This script for adding rows seems to be a bit off, please help fix it!
- December 26, 2024
- 3 replies
- 1498 views
This script is used to determine if there is already a table header and add a row if there isn't.
Since this script doesn't require the table to be selected in full, I like it.
I found the script to be correct if there is only one table.
However, if there are more than two tables, my cursor is already inside the second table, but mytable still points to the previous table table[0].
//first mytable in the active document
var mytable=app.activeDocument.textFrames[0].parentStory.tables[0]
var firstRow = mytable.rows[0];
//to header and add 1 row;
if (firstRow.rowType !== RowTypes.HEADER_ROW)
{
dupeTopRow(mytable);
mytable.rows.add(LocationOptions.BEFORE, mytable.rows[0]);
}
else{
alert("header exist")
exit ();
}
