Copy link to clipboard
Copied
Hi Experts
I wrote little Script to convert first table rows to header row, and it work good for the first time but if i ran the script again after converting every table first row to header in all tables it give an error? how i can avoid that? because if i add new tables needed to be convert their first row it will not work again and give error!, so how i can let the script ignore the errors and continue to find any new tables needed to be convert its first table row! and thanks in advance
//Convert Every First Table Row to Header Row
var myDoc = app.activeDocument;
var myRows = myDoc.stories.everyItem().tables.everyItem().rows[0].getElements();
for (var i = 0; i < myRows.length; i++) {
if (myRows[i].rowType == RowTypes.BODY_ROW);
myRows[i].rowType = RowTypes.HEADER_ROW;
}
The Error Message for the Second time
The problem is with your if statement, remove the ; after the if and it will work fine. In the current state the if statement has no effect as the statement it's controlling is a blank statement denoted by a ; The line after it is executed always and hence you see the error
-Manan
Copy link to clipboard
Copied
The problem is with your if statement, remove the ; after the if and it will work fine. In the current state the if statement has no effect as the statement it's controlling is a blank statement denoted by a ; The line after it is executed always and hence you see the error
-Manan
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Also, It may not work if any cell has rowSpan greater than 1.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now