Copy link to clipboard
Copied
I have the following that works just fine in Indesign 2020 and eariler, but I can not get it to work in anything later. Any one know how to get it working in 2022?
var myColor = app.documents[0].colors.itemByName("red");
// Is it really there?
if( myColor.isValid )
{
myColor.properties =
{
model : ColorModel.SPOT ,
space : ColorSpace.CMYK ,
colorValue : [0,100,80,0]
}
}
I appriciate everyones help.
After learning here that it works in 17.2 I tried it on a friends Mac and it also worked.
Turns out I had to delete my Indesign preferences to get it going on mine.
Thanks again
Paul
Copy link to clipboard
Copied
Hi,
works as it should in 17.1 – assuming you already have a swatch called "red" in your document – otherwise your snippet does nothing (as expected).
Do you get an error message?
Copy link to clipboard
Copied
Sorry, I should have been more precise in what "does not work"
If I have a swatch red defined with a color value of 0,85,85,0
and run the script, it should change the color value of the red swatch to 0,100,80,0
It does this in 15.1.4, but does not in 17.2.
And I do not get an error at all.
Copy link to clipboard
Copied
Hi paul.abney@emprinting.com, I can confirm it works as expected in Indesign 17.2 MacOS.
A clue could be that you don't get an error. This might be because your code doesn't do anything if the color is invalid. See slightly modified script below. Also note that the colorName is case sensitive.
- Mark
var colorName = "Red";
var myColor = app.documents[0].colors.itemByName(colorName);
// Is it really there?
if (myColor.isValid) {
myColor.properties = {
model: ColorModel.SPOT,
space: ColorSpace.CMYK,
colorValue: [0, 100, 80, 0]
}
}
else {
// color not valid, probably not in document
alert('Could not find color "' + colorName + '".');
}
Copy link to clipboard
Copied
Hi Paul,
I can see this as well. But only if there is no named color with "red" in its name.
Check the exact name of your color "red" in the Swatches panel of your document.
Perhaps it's "Red" with a capital "R" and not "red".
Hm. Or the name of your color starts with "red", but has a trailing white space after the "d" like "red ".
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
"It does this in 15.1.4, but does not in 17.2."
Please provide your InDesign test documents for each of the versions.
Put them on Dropbox or a similar service and post the download link.
Thanks,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
I appriciate everyones help.
After learning here that it works in 17.2 I tried it on a friends Mac and it also worked.
Turns out I had to delete my Indesign preferences to get it going on mine.
Thanks again
Paul