Can't assign a name to a swatch color with script
Hello!
With the following script, I want to rename a range of colors in my swatch from 1 to x.
var doc = app.activeDocument;
var swatches = doc.swatches;
var firstColorID = 16;
var lastColorIDfromEnd = 4;
RenameSwatchesColors(firstColorID, lastColorIDfromEnd);
function RenameSwatchesColors(firstID, lastID) {
var swatchesLength = swatches.length;
var newName = 1;
for (var i = firstColorID; i < swatchesLength - lastColorIDfromEnd; i++) {
alert(swatches[i].name);
swatches[i].name = newName.toString();
newName++;
}
}If I only left the alert part that display the color name, everything is ok! The range is good, all colors within it are properly called.
When I assigned the name with "swatches[i].name = ", for some reason that I don't understand I got an error : "Exception has occured 8701. The name was not found".
But it was displayed with the alert! So it's basically an assignation problem, but why? I don't see any differences from others colors in the swatch. I have even tried to delete and recreate the problematic colors, but nothing changed.
Thank you if you have any clue...
