3 Replies Latest reply on Mar 21, 2012 1:58 AM by Trevorׅ

    coloring a table in one (not too long) line.

    Trevorׅ Adobe Community Professional

      Is there a way of coloring a table or cell a swatch color in one shot without having to go through: bottomEdgeStrokeColor = myColor, topEdgeStrokeColor = myColor, leftEdgeStrokeColor = myColor, rightEdgeStrokeColor = myColor?

       

      Not the end of the world if not but would be nice

        • 1. Re: coloring a table in one (not too long) line.
          [Jongware] Most Valuable Participant

          There aren't that many advantages to try and do lots of stuff in one line (and disadvantages include readability and maintainability), but there you go:

           

          myTable = app.selection[0].parentStory.tables[0];
          myColor = app.activeDocument.swatches.item("red");
          myTable.cells.everyItem().properties = {bottomEdgeStrokeColor:myColor, topEdgeStrokeColor:myColor, leftEdgeStrokeColor:myColor, rightEdgeStrokeColor:myColor};
          
          1 person found this helpful
          • 2. Re: coloring a table in one (not too long) line.
            Trevorׅ Adobe Community Professional

            HiJongware,

             

            Thanks for you quick reply, for some reason I didn't get the Email notification.

            I was thinking more of using a variable for use with the "with" command.

            something like

             

            myStokeColors = "bottomEdgeStrokeColor = myColor; topEdgeStrokeColor = myColor; leftEdgeStrokeColor = myColor; rightEdgeStrokeColor = myColor";
            myCellStyle = myDoc.cellStyles.add({name:"myCellStyle"});
              with (myCellStyle){ 
                  appliedParagraphStyle = "myParaStyle";
                  bottomInset =1;
                 myStokeColors;
                  }
            

            any ideas?

            • 3. Re: coloring a table in one (not too long) line.
              Trevorׅ Adobe Community Professional

              I got it.

              It's useful if you have a lot of styles with the same stroke color or other property

              Thanks for the giveaway clue

               

              myDoc = app.activeDocument;
              myColor = app.activeDocument.swatches.item("C=0 M=100 Y=0 K=0");
              magentaStroke = {bottomEdgeStrokeColor:myColor, topEdgeStrokeColor:myColor, leftEdgeStrokeColor:myColor, rightEdgeStrokeColor:myColor}; // sets all edges to color
              myColor = app.activeDocument.swatches.item("C=100 M=0 Y=0 K=0");
              cyanStroke = {bottomEdgeStrokeColor:myColor, topEdgeStrokeColor:myColor, leftEdgeStrokeColor:myColor, rightEdgeStrokeColor:myColor};
              try {myCellStyleMagenta = myDoc.cellStyles.add({name:"myCellStyleMagenta"});}
              catch (exist) {myCellStyleMagenta = myDoc.cellStyles.item("myCellStyleMagenta");}
                  with (myCellStyleMagenta){ 
                    bottomInset =1;
                   properties = magentaStroke; // applies color to cell style
                    }
                try {myCellStyleCyan = myDoc.cellStyles.add({name:"myCellStyleCyan"});}
              catch (exist) {myCellStyleCyan = myDoc.cellStyles.item("myCellStyleCyan");}
                  with (myCellStyleCyan){ 
                    bottomInset =1;
                   properties = cyanStroke;
                    }