Here is my attempt:
function makeAllTextBlack() {
var document = app.activeDocument,
textFrames = document.textFrames,
nbTextFrames = textFrames.length,
swatch = document.swatches.item("C=100 M=100 Y=100 K=100"),
i;
for (i = 0; i < nbTextFrames; i +=1) {
textFrames[i].fillColor = swatch;
}
}
makeAllTextBlack();
When running this script in the ExtendScript Toolkit, it complains that the value defined for the fillColor property is incorrect, saying that it expected a Swatch or a String but received nothing. Is there something wrong with my swatch?
The swatch you get that way is invalid, even if you try to get it by name (itemByName) don’t ask me why, but it is better to use Color objects. For example you could do this to create the color:
Then apply it directly to the fillColor property.
(one remark, textFrames.fillColor will not change the texts color, but the TextFrame background… I think you want to iterate the texts on each TextFrame and change their fillColor.)