I'm looking to put together a script which will loop through documents' pages and apply master spreads based on the occurrence of certain styles. All the documents have four sections; some of them have five or six. One paragraph style signals the beginning of a section and another denotes the last page of the section. These paragraphs all occur on discrete pages. Basically, the structure looks like the following:
Section Head (Paragraph Style)
Section 1 Content
Section End (Paragraph Style)
Section Head (Paragraph Style)
Section 2 Content
Section End (Paragraph Style)
Section Head (Paragraph Style)
Section 3 Content
Section End (Paragraph Style)
Section Head (Paragraph Style)
Section 4 Content
Section End (Paragraph Style)
I just want the script to apply the appropriate master spread (Section 1, Section 2, etc.) to the page range for each section. Any help would be greatly appreciated. Thanks!