Skip to main content
Inspiring
August 21, 2017
Answered

fillColor changes the colour of all pages

  • August 21, 2017
  • 3 replies
  • 717 views

I run this line with a text frame selected:

app.selection[0].paragraphs[0].fillColor.colorValue = [0,0,0,100];

and instead of changing the fillColor of the paragraph, every page (including the master page) and every paragraph is changed to black.

What am I missing?

This topic has been closed for replies.
Correct answer Laubender

Hi Jake,

you changed the value of an applied color. You did not apply a new color to the paragraph.

If you want to use [Black] on the text you could do it like that:

app.selection[0].paragraphs[0].fillColor = app.documents[0].colors.itemByName("Black");

or perhaps like that:

app.selection[0].paragraphs[0].fillColor = "Black";

If you need a color that is not the standard [Black], but is different, create one before using it:

var myNewBlack = app.documents[0].colors.itemByName("MyNewBlack");

if(!myNewBlack.isValid)
{

app.documents[0].colors.add

(

{

name : "MyNewBlack" ,

colorValue : [0,0,0,100] ,

model : ColorModel.PROCESS ,

space : ColorSpace.CMYK

}

)

};

app.selection[0].paragraphs[0].fillColor = myNewBlack;

Without seeing your document I cannot tell what exactly happened after your try…

Regards,
Uwe

3 replies

Inspiring
August 22, 2017

Thanks Uwe

Great explanation!

LaubenderCommunity ExpertCorrect answer
Community Expert
August 22, 2017

Hi Jake,

you changed the value of an applied color. You did not apply a new color to the paragraph.

If you want to use [Black] on the text you could do it like that:

app.selection[0].paragraphs[0].fillColor = app.documents[0].colors.itemByName("Black");

or perhaps like that:

app.selection[0].paragraphs[0].fillColor = "Black";

If you need a color that is not the standard [Black], but is different, create one before using it:

var myNewBlack = app.documents[0].colors.itemByName("MyNewBlack");

if(!myNewBlack.isValid)
{

app.documents[0].colors.add

(

{

name : "MyNewBlack" ,

colorValue : [0,0,0,100] ,

model : ColorModel.PROCESS ,

space : ColorSpace.CMYK

}

)

};

app.selection[0].paragraphs[0].fillColor = myNewBlack;

Without seeing your document I cannot tell what exactly happened after your try…

Regards,
Uwe

Jump_Over
Legend
August 21, 2017

Hi,

Check if this color is named - in this case code is modifying an object - color possibly used many times across:

alert (app.selection[0].fillColor.name) ;

Jarek

Inspiring
August 22, 2017

Hi Jarek,

How would I go about doing it if it was an object?