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

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

Guru ,
Mar 20, 2012 Mar 20, 2012

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

TOPICS
Scripting
810
Translate
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

Guru , Mar 21, 2012 Mar 21, 2012

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, topEdgeStrokeCol

...
Translate
Community Expert ,
Mar 20, 2012 Mar 20, 2012

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

Translate
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
Guru ,
Mar 20, 2012 Mar 20, 2012

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?

Translate
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
Guru ,
Mar 21, 2012 Mar 21, 2012
LATEST

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;

      }

Translate
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