• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

InDesign script to delete table rows containing specific text

Explorer ,
Jun 26, 2018 Jun 26, 2018

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!

TOPICS
Scripting

Views

2.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Jun 26, 2018 Jun 26, 2018

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]

...

Votes

Translate

Translate
Advocate ,
Jun 26, 2018 Jun 26, 2018

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++;

    }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 26, 2018 Jun 26, 2018

Copy link to clipboard

Copied

This is perfect, thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 18, 2023 Apr 18, 2023

Copy link to clipboard

Copied

LATEST

how would I adjust this so it would delete empty rows without any content?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines