Applying Paragraph Style then Next Style not Working as Expected via JavaScript
Hi Experts, I Hope you are all fine, I'm trying to apply Paragraph Style then Next Style Automatically Based on Previous Found Style, heres is my code and Screen Shot, the Probelm is everytime excuting the code it only Apply Paragraph Style (AnswerStyle_B) to first Line after QuestionStyle Line and Ignore the rest of Lines, I'm trying to achive this Automatically via Script on all lines So Every line Start with A. will take the Style (AnswerStyle_A) and the Others (B-C-D) will take the Style (AnswerStyle_B) , I'm Still Learning JavaScript and try to figure out some problems , Please Help and Thanks in Advance :
var doc = app.documents[0];
app.findTextPreferences = null;
app.findTextPreferences.appliedParagraphStyle = "QuestionStyle";
var myResults = app.activeDocument.findText();
for (i=0; i<myResults.length; i++)
myResults[i].parentStory.paragraphs.nextItem(myResults[i].paragraphs[0]).appliedParagraphStyle = app.activeDocument.paragraphStyles.item("AnswersStyle_A").nextStyle;
