Hi
I have a large document (potentially 3000 pages), on each page is a graphic of a picture frame and inside each frame is a famous quotation. I need to have the type in each quotation set in a different font so i’ve setup 10 different paragraph styles. I need a script that will apply ‘QuoteStyle1’ to the text on the first page, ‘QuoteStyle2’ to the next page etc, and once ‘QuoteStyle10’ has been applied the script loops and continues to cycle through the styles applying a different style on each page until it reaches the end of the document.
I’ve made a start on the script but I think the problem is line 11 – I want to run the script without having to select anything.
Here’s the script i’ve got so far:
paraStyleList = [ “QuoteStyle1”, “QuoteStyle2”, “QuoteStyle3”, “QuoteStyle4”, “QuoteStyle5”, “QuoteStyle6”, “QuoteStyle7”, “QuoteStyle8”, “QuoteStyle9”, “QuoteStyle10” ];
skipStyle1 = app.activeDocument.paragraphStyles.item(“VisibleName”);
skipStyle2 = app.activeDocument.paragraphStyles.item(“ColourPink”);
skipStyle3 = app.activeDocument.paragraphStyles.item(“ColourYellow”);
skipStyle4 = app.activeDocument.paragraphStyles.item(“ColourGreen”);
skipStyle5 = app.activeDocument.paragraphStyles.item(“ColourBlue”);
skipStyle6 = app.activeDocument.paragraphStyles.item(“ColourRed”);
skipStyle7 = app.activeDocument.paragraphStyles.item(“ColourPurple”);
skipStyle8 = app.activeDocument.paragraphStyles.item(“ColourOrange”);
story = app.selection[0].parentStory;
currentPStyle = 0;
for (i=0; i<story.paragraphs.length; i++)
{
if (i > 0 && story.paragraphs[i].contents.match(/[\u]/))
{
currentPStyle = currentPStyle+1;
if (currentPStyle == paraStyleList.length) currentPStyle = 0;
}
if (story.paragraphs[i].appliedParagraphStyle != skipStyle1)
if (story.paragraphs[i].appliedParagraphStyle != skipStyle2)
if (story.paragraphs[i].appliedParagraphStyle != skipStyle3)
if (story.paragraphs[i].appliedParagraphStyle != skipStyle4)
if (story.paragraphs[i].appliedParagraphStyle != skipStyle5)
if (story.paragraphs[i].appliedParagraphStyle != skipStyle6)
if (story.paragraphs[i].appliedParagraphStyle != skipStyle7)
if (story.paragraphs[i].appliedParagraphStyle != skipStyle8)
{
story.paragraphs[i].appliedParagraphStyle = paraStyleList[currentPStyle];
}
}
Some further info that may or may not be of use – All of the quotes are being pulled in from a data-merge. There’s also a name and a colour coming from the data-merge. The background on each picture frame is a different colour and that is created with the a very large ‘Rule Below’ in a number of other paragraph styles. These are being applied with a ‘Find&ReplacebyList’ i.e. find ‘Red’ replace with paragraph style ‘ColourRed’. In the script i’ve tried to skip these ‘Colour’ paragraph styles (lines 2-9) so it’s only the ‘Quote’ styles that the script effects.
Any help getting this running would be most helpful.