1 Reply Latest reply on Oct 8, 2014 12:31 AM by BEGINNER_X

    Delete last column in a table

    Elp

      Hey there,

       

      is it possible that a script selects the last column of a table (there are tables with 3 and 4 columns on a page) and deletes it?

      And is it possible that this happens on a specific layer?

       

      Greetings

        • 1. Re: Delete last column in a table
          BEGINNER_X Level 3

          Hi Elp,

           

          Use the below code:

           

          //remove column
          var myTable = app.activeDocument.stories.everyItem().tables.everyItem().columns[-1].remove();
          
          
          //remove column with layer
          var myTable = app.activeDocument.stories.everyItem().tables.everyItem().getElements();
          alert(myTable.length)
          
          
          for(i=0; i<myTable.length; i++)
          {
              if(myTable[i].parent.itemLayer.name == "aaa")
              {
                  app.select(myTable[i].columns[-1]);
                  myTable[i].columns[-1].remove();
                  }
              
              }
          

           

           

          Regards

          Siraj