2 Replies Latest reply on Jul 31, 2015 1:47 PM by Johnwhite

    How to change table properties

    Johnwhite Level 1

      Hi experts,

       

      How to change cells properties.

       

      how to make the script as below working.

       

      Could someone show me how

       

      Regard

      John

       

            var

             doc = app.documents,

             myStories = doc.story.everyItem().getElements(),

             cStory, cText, myTables, cTable;

            while (cStory = myStories.pop() ) {

             cText = cStory.texts[0];

             if (!cText.isValid) continue;

                                          cText.fillColor = "Black";

                                          myTables = cText.tables.everyItem().getElements();

             while (cTable = myTables.pop() ) {

                                              if (!cTable.isValid) continue;

                                                  cTable.cells.everyItem().texts.everyItem().tabStops[0].alignmentCharacter = ".";  

                                                  cTable.cells.everyItem().texts.everyItem().fillColor = "Black";  

                                                  cTable.cells.everyItem().fillColor = "Paper";  

                                                  cTable.cells.everyItem().leftEdgeStrokeColor = "Paper";  

                                                  cTable.cells.everyItem().rightEdgeStrokeColor = "Paper";  

                                                  cTable.cells.everyItem().topEdgeStrokeColor = "Paper";  

                                                  cTable.cells.everyItem().bottomEdgeStrokeColor = "Paper";  

              }  

             }

        • 1. Re: How to change table properties
          Jump_Over Level 5

          Hi John,

           

          As far as I know we can use "chain of everyItem()" here with 2 conditions:

          1. there is at least 1 story in a doc

          2. there is at least 1 table in a doc

           

          so this code should work:

           

          var cStoriesCheck = app.activeDocument.stories.everyItem().getElements().length;
          if (!cStoriesCheck ) exit();
          var cTablesCheck = app.activeDocument.stories.everyItem().tables.everyItem().getElements().length;
          
          app.activeDocument.stories.everyItem().texts.everyItem().fillColor = "Black"
          if (!cTablesCheck) exit(); 
          with ( cStories.tables.everyItem().cells.everyItem() ) {
               texts.everyItem().fillColor = mBlack; 
               texts.everyItem().tabStops.everyItem().alignmentCharacter = ".";
               fillColor = "Paper"; 
               leftEdgeStrokeColor = "Paper";  
               rightEdgeStrokeColor = "Paper";  
               topEdgeStrokeColor = "Paper";   
               bottomEdgeStrokeColor = "Paper";     
               }
          
          • 2. Re: How to change table properties
            Johnwhite Level 1

            thank you Jarek

            thank you so much