To access a paragraph style in a group, you need to reference it like so:
var myParStyle = app.activeDocument.paragraphStyleGroups.item("xSports").paragraphStyles.item("AGPPRegular ");
app.activeDocument.stories.lines[iLoop].appliedParagraphStyle = myParStyle;
Why do you apply paragraph styles to lines? As to me, it makes more sense to apply them to paragraphs:
app.activeDocument.stories.paragraphs[iLoop].appliedParagraphStyle = myParStyle;
Thanks for the reply.
It just seems strange that InCopy can read (and writes) a tagged file with the 'xSports\: AGPPRegular' syntax, but insists on a reference to paragraphStyleGroups in script.
This script goes through the many lines of a baseball box score and applies the appropriate paragraph style, based on number of tabs, presence/absence of certain words, etc. Source files are created on various systems, and 'paragraph' is not always interpreted the same way. 'Line' has been much more reliable.
applies the appropriate paragraph style, based on number of tabs, presence/absence of certain words, etc.
Why not to use GREP styles feature then? You are on CS4.
You are right about GREP. Most of my scripting work was done five years ago with InCopy/InDesign CS. There are so many new tools now! However, current project deadlines require that code be turned over fairly quickly. I look forward to investigating all CS4's features as soon as the pressure is off.