Okay, I got it to work with the rather sloppy:
if (!(col.Name in {"Custom1":"", "Custom2":"", "Custom3":""}))
Thankfully we only have three corporate colors so this isn't too ugly. If someone has time, I would like to see a cleaner method of checking against an array (or list) of items as my next project is to clean out variables for which we have tons that are no longer acceptable.
Thanks
Milo
Try this as one way to solve the problem. It adds a new contains() method to the Array class.
var doc = app.ActiveDoc,
col = doc.FirstColorInDoc
keepColors = ["Black","White","Red","Green","Blue","Cyan","Magenta","Yellow","Dark Grey","Pale Green","Forest Green","Royal Blue","Olive","Salmon","Mauve","Light Salmon","Custom Color"];
Array.prototype.contains = function (value) {
var i;
for (i = 0; i < this.length; i+=1) {
if (this === value) {
return true;
}
}
}
while(col.ObjectValid()){
if (!keepColors.contains(col.Name)) {
col2 = col.NextColorInDoc;
col.Delete();
col = col2;
}
else {
col = col.NextColorInDoc;
}
}