Is it possible to apply [None] Swatch/Color to a TextFrame contents ?
I currently use this:
var vNoneColor = app.swatches.itemByName("None");
for (var iText=0; iText < vTextFrame.texts.length ; iText++)
var vText = vTextFrame.texts.item(iText);
vText.fillColor = vNoneColor
or maybe create my own Color but it's not possible to change transparency.
You should really use the locale independent name
@Harbs – in my German InDesign " fillColor = "None" " does work as expected. Are there other localized versions of InDesign where this does not work?
So this does the job:
myTextFrame.texts.fillColor = "None";
You should really use the locale independent name:
var noColor = doc.swatches.itemByName("$ID/kNoneName");
I'm afraid this is no correct in the specific case of swatches—and the code above should not work in non-EN languages.
Whatever the locale the None swatch has always the internal name "None"—even if it is localized in the Swatch panel as [None], [Sans], [Ohne], etc. (depending on the locale). This fact is very specific to the Swatches collection, which basically uses None, Black, Paper and Registration as unique reserved names in a locale-independent way. (By contrast, the reserved names of the styles collection, including None, are locale-dependent!)
As a consequence, the regular way to point out to the None swatch in any language, is:
var noneSwatch = myDoc.swatches.itemByName('None'); alert( noneSwatch.isValid ); // should always be true alert( noneSwatch.name ); // should always be"None"
Likewise, the shortcut to apply this swatch, in any language, is:
myObj.fillColor = "None";
whereas myObj.fillColor = "$ID/kNoneName" will fail in non-EN locales because this actually means:
myObj.fillColor = app.translateKeyString("$ID/kNoneName");
myObj.fillColor = "Ohne"; // in German => error
myObj.fillColor = "Sans"; // in French => error
By contrast, name-based access to special object styles can be done locale-dependently, and should be done locale-independently:
var noneStyle = myDoc.objectStyles.itemByName('$ID/[None]'); // OK
Europe, Middle East and Africa