Help with script to insert text with an applied style from a style group
I know very little about scripting but have been able to cobble together a a few things for my own use.
Now I'm trying to write a script to insert text at the insertion point with an applied character style from a style group, with the text string, the style name, and the style group name all defined in the script. The following is what I've cobbled together from examples I've found.
If I leave out the third line that defines myStyle and change the reference in the last line to the character style name "Prime" it works -- but the character style "Prime" can't be in a style group.
I'd really appreciate any help with that issue or with making the script less kludgy overall. thanks.
var myNewString = String.fromCharCode(0x2032); // prime mark
var myTextFrame = app.selection[0].parentTextFrames[0];
var myStyle = app.documents[0].paragraphStyleGroups.item("Auto").paragraphStyles.item("Prime");
var styleStartIndex = app.selection[0].index;
var styleEndIndex = styleStartIndex + myNewString.length - 1;
app.selection[0].contents = myNewString;
myTextFrame.characters.itemByRange(styleStartIndex, styleEndIndex).appliedCharacterStyle = myStyle;
