4 Replies Latest reply on Sep 13, 2013 3:58 AM by Vimala lakshmanan

    How to ungroup the particular table in Indesign using javascript?

    Vimala lakshmanan

      Hi,

       

      I have written a script for removing dotted lines at the end of text,which has presented inside the table.but this script is not working for the table that has grouped in InDesign.First I want to ungroup the particular table and remove dotted lines,then i need to group that table again.please help me if anyone has idea regarding this.

       

      Thanks in advance!

      Vimala L

        • 1. Re: How to ungroup the particular table in Indesign using javascript?
          Laubender Adobe Community Professional & MVP

          @Vimala Lakshmanan – to access tables inside text frames of grouped objects, you need not to ungroup.

           

          You could use the Group objects and iterate through all page items of the group, single out the text frames and access their Texts object and their Tables object within.

           

          By starting with a Group object (in the following snippet the group is selected):

           

          var myGroup = app.selection[0];
          
          var allPageItemsOfGroup = myGroup.allPageItems;
          
          for(var n=0;n<allPageItemsOfGroup.length;n++){
          
              var myObject = allPageItemsOfGroup[n].getElements()[0];
          
              if(myObject.constructor.name === "TextFrame" && myObject.texts[0].tables.length > 0){
          
                  var myTables = myObject.texts[0].tables;
          
                  for(var t=0;t<myTables.length;t++){
          
                      //Do your stuff here:
          
                      //Just an example line, that fills all cells in a table to "Yellow"
                      myTables[t].cells.everyItem().fillColor = "Yellow";
          
                      };
          
                  };
          
          };
          

           

          This snippet also considers nested groups, anchored text frames and nested text frames.
          It does not consider objects in not active states of MultiStateObjects.

           

          Uwe

          • 3. Re: How to ungroup the particular table in Indesign using javascript?
            Laubender Adobe Community Professional & MVP

            @Vimala Lakshmanan – I still do not know, if the scope of your script is restricted to certain objects or certain pages.

             

            If the scope is the whole document AND there are no tables nested to cells in tables (another scope restriction in my snippet above!) you could also iterate to all Story objects of a document accessing the tables.

             

            You could also go directly for all tables, if the target cells are the same.

             

            Here an example that targets the last row of every table in every story in the document:

             

            app.documents[0].stories.everyItem().texts[0].tables.everyItem().rows[-1].cells.everyItem().fillColor = "Yellow";
            

             

            Uwe

            • 4. Re: How to ungroup the particular table in Indesign using javascript?
              Vimala lakshmanan Level 1

              Hi,

               

              Thanks for ur reply..First i have tried to write a script for ungroup a particular table.,but it(ungroup) also applied to the images which has presented in the document.so that i asked the script for ungroup a particular table.

               

              Thanks,

              Vimala L