var doc, textRange;
doc = app.ActiveDoc;
textRange = doc.TextSelection;
applyTextColor (textRange, "Black", doc);
function applyTextColor (textRange, colorName, doc) {
var color, prop;
// Get the color object.
color = doc.GetNamedColor (colorName);
// Make sure the color exists in the document.
if (color.ObjectValid () === 1) {
// Make a property list containing the color.
prop = new PropVal ();
prop.propIdent.num = Constants.FP_Color;
prop.propVal.valType = Constants.FT_Id;
prop.propVal.obj = color;
// Apply the color to the text.
doc.SetTextPropVal (textRange, prop);
}
}
... View more