Hi…if anyone feels inclined, could you offer suggestions for improving this script (I know there’s no error trapping, etc, but those aren’t the suggestions I’m looking for ). The idea of this script is to find all occurences of a certain heading, and then set the style of the paragraph AFTER that heading to a style that has no space above.
My 2 problems are as follows:
I work with long documents, so if the heading (whose object references I am gathering) appears many, many times, the script bombs out from what I believe is an overrun of the list it compiles. Is this conceivable? I realize there were list limitations but I thought using the latest version of applescript and editor avoided these.
Except in the case above, the script quickly gathers the object references…but it completely bogs down when trying to change the style of the paragraph AFTER (or the para before when I write the script in an opposite way). If I wait long enough, it manages to work, but it takes several minutes when there are only a few cases to change (with the Force Quit screen showing InDesign “not responding”). Is there a better way to reference the paragraph after an object reference? I seem to run into the same problem using offsets, and I can’t figure out how to use paragraph index, because when I check properties of the paragraphs, the index numbers of the paragraphs don’t seem to run in an order…so I can’t say (+1).
Anyway, here’s my measely script that would save me tons of time and money if it worked better…
--Gets style refs, change para after to new style tell application "Adobe InDesign CS2" activate tell document 1 set changeStyle to paragraph style "@NoSpace" tell parent story of the selection -- text frame selected set myParas to (object reference of paragraphs whose (name of applied paragraph style is "@Head1")) repeat with i from (count of myParas) to 1 by -1 set applied paragraph style of (paragraph after item i of myParas) to changeStyle end repeat end tell end tell end tell
Thanks in advance to anyone who can offer an idea. BF (OS 10.3.9/ID CS2)