Copy link to clipboard
Copied
I need to convert first row of all the tables to header row. I tried all the possible ways which are mentioned below, but am getting the error (can't set row type) . After researched about this error I got to know that this is a read only property so can't change row type in a table. How can I fix this?
1.
var myTables = app.activeDocument.stories.everyItem().tables;
for (var i = 0; i < myTables.length; i++) {
myTables.rows.firstItem().rowType = RowTypes.HEADER_ROW;
}
2.
app.activeDocument.stories.everyItem().tables.everyItem().rows[0].rowType=RowTypes.HEADER_ROW;
3.
var myRows = app.activeDocument.stories.everyItem().tables.everyItem().rows[0].getElements(),
myCells = app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem(),
l = myRows.length;
while (l--) if (myRows
Copy link to clipboard
Copied
Your first method itself working fine for me..
var myTables = app.activeDocument.stories.everyItem().tables;
for (var i = 0; i < myTables.length; i++) {
myTables.rows.firstItem().rowType = RowTypes.HEADER_ROW;
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Thanks Karthi for the code and the links!
Copy link to clipboard
Copied
Share the error screen please
PS: Obi-wan Kenobi, i copied OP code not mine
Copy link to clipboard
Copied
Oups! 😉
Copy link to clipboard
Copied
I have not read the other posts, but the first code fails, because 'myTables.rows.firstItem()' repesents not the result of one row!
The second code ' app.activeDocument.stories.everyItem().tables.everyItem().rows.firstItem().rowType = RowTypes.HEADER_ROW; '
fails, if there is already one table with a header row.
So I would do it in this way:
var myTables = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
for (var i = 0; i < myTables.length; i++) {
var curTable = myTables;
var firstRow = curTable.rows[0];
if (firstRow.rowType != RowTypes.HEADER_ROW) {
firstRow.rowType = RowTypes.HEADER_ROW;
}
}
Kai
Copy link to clipboard
Copied
But am getting ERROR: Can't set row type
Find more inspiration, events, and resources on the new Adobe Community
Explore Now