Copy link to clipboard
Copied
Am after a script to search through all table rows of tables in the current document for specific text. In this instance it's "BLANKITYBLANK". Once it finds said text I want it to then delete/remove that entire table row. I have done some thorough searching the forums however can only seem to find scripts relating to empty rows.
I'm sure this is possible just not sure how to go about it.
Thanks in advance!
Hi,
You should try this below code,
...var allStories = app.documents[0].stories;
var st = 0;
while(st < allStories.length){
var allTables = allStories[st].tables;
var tbl = 0;
while(tbl < allTables.length){
var allCells = allTables[tbl].cells;
var cel = 0;
while(cel < allCells.length){
if(allCells[cel].contents.toString().toLowerCase().indexOf("blankityblank") != -1){
allCells[cel].rows[0].remove();
allCells = allTables[tbl]
Copy link to clipboard
Copied
Hi,
You should try this below code,
var allStories = app.documents[0].stories;
var st = 0;
while(st < allStories.length){
var allTables = allStories[st].tables;
var tbl = 0;
while(tbl < allTables.length){
var allCells = allTables[tbl].cells;
var cel = 0;
while(cel < allCells.length){
if(allCells[cel].contents.toString().toLowerCase().indexOf("blankityblank") != -1){
allCells[cel].rows[0].remove();
allCells = allTables[tbl].cells;
cel = -1;
}
cel++;
}
tbl++;
}
st++;
}
Copy link to clipboard
Copied
This is perfect, thanks!
Copy link to clipboard
Copied
how would I adjust this so it would delete empty rows without any content?