is now part of CreativePro.com!

Find Change the Next Paragraph Style with a Script

22

Here’s a feature I wish were in InDesign: I want a way to add to a paragraph style definition, “Use a 1p6 first line indent… unless the paragraph comes after a heading or subheading!” As it is, because we don’t have that feature, I have to use two different pararaph styles (usually something like “body” and “body with no indent”).

Even more frustrating, I have to apply each of those styles separately, making sure they’re applied to the proper pargraph. If the text gets edited, I often have to go back and reapply the proper styles. Grr.

That’s why I jumped when I saw a new script by Thomas Silkjær that lets you find/change the paragraph styles for “this paragraph and the one following it.” Unfortunately, because it’s an AppleScript, it will only work on a Mac. However, perhaps he’ll release a VB or JSX version at some point. Or perhaps other scripters will even improve on his idea.

Here’s the basic UI for the script (using the paragraph styles in my document):

I’m actually not sure what the text at the bottom of the dialog box means, but the script seems to work well in my quick tests (as long as you have your text cursor in a story).

David Blatner is the co-founder of the Creative Publishing Network, InDesign Magazine, CreativePro Magazine, and the author or co-author of 15 books, including Real World InDesign. His InDesign videos at LinkedIn Learning (Lynda.com) are among the most watched InDesign training in the world.
You can find more about David at 63p.com

Follow on LinkedIn here
  • Harbs says:

    Hi David,

    I think you should take a better look at Formatting Tools. ;)

    Formatting Tools is a collection of utilities which does these kinds of formatting tasks. Apparently, “Consecutive Styles” does the same thing as this script. There’s currently three other utilities, and I’m waiting for suggestions for more… :)

  • Oh my! I hadn’t seen that utility in Formatting Tools! Thank you for pointing that out. In fact, Formatting Tools has several other awesome features, too, such as the ability to apply a paragraph style automatically based on codes (or styles) at the beginning of the paragraph. That is very helpful for people who want to import ascii text with codes in it and style it “austomatically.”

    And that’s a very inexpensive plug-in! Cool.

  • EnergonCube says:

    David,

    To “force apply” a style is that same as holding option when applying a style — it clears out all local formatting first and then applies the style.

    So, in this case, if you have a character style in the paragraph that is changing, it will not be removed when the new style is applied.

  • john renfrew says:

    here’s a factor though

    free/ 29 dollars

    and with the free one you can take it to pieces to learn stuff

    Just buying plugins doesnt help the rest of us develop scripts

  • I have republished the script – now in JS, so it should work in Windows too. Thanks for the mention btw!

  • Anne-Marie says:

    Thank you Thomas! (and Harbs!)

    A note to everyone who uses free scripts: TANSTAAFS … that is, to riff on Robert Heinlein, there ain’t no such thing as a free script.

    Everyone’s time is worth something. To encourage and support the freebies that people like Thomas publish, please consider making a donation to their Paypal accounts (only if you actually use the script of course). You’re paying for software so it should be a business expense/write-off.

    Thomas has a Donate button on the script page that David links to. Look at the bottom of the left sidebar.

  • Louis says:

    Hi! I hope someone on this site can help me!

    I am having a problem with find/change related to what EnergonCube wrote on April 20:

    “…if you have a character style in the paragraph that is changing, it will not be removed when the new style is applied..”

    I am trying to assign a new paragraph style to certain paragraphs in a document.
    It is easy to find these paragraphs because they all have a specific left indent or a specific hanging indent.
    However, these paragraphs also have lots of character formats: bold words and superscript footnote reference numbers, in particular. When I use “find/change” to assign the style individually to each paragraph that meets the search criteria, no problem, the style is changed and the character styles are maintained. But when I use “change all”, the style is changed but all character styles are erased! I want to keep the character styles, but I also want to speed up the process of assigning the style (I am only doing some tests for now, but ultimately, there will be thousands of these paragraphs to format).
    What can I do?

  • Louis, the best option in my opinion is to create character styles for bold, italic, bold/italic etc, and start off by searching for bold text, applying the bold character style etc.

    If text formatting is applied through a character style, it will not be override by the paragraph style, that is the force of character styles. Local formatting will be override by paragraph styles, unless they are applied “without force apply”.

    /Thomas

  • Po says:

    To make the script work with paragraph style groups, replace the i counter with the b counter in the following 2 places:

    Change:
    list_of_paragraph_styles.push(the_document.paragraphStyleGroups[i].name+’/’+the_document.paragraphStyleGroups[i].paragraphStyles[i].name);
    all_paragraph_styles.push(the_document.paragraphStyleGroups[i].paragraphStyles[i]);

    To:
    list_of_paragraph_styles.push(the_document.paragraphStyleGroups[i].name+’/’+the_document.paragraphStyleGroups[i].paragraphStyles[b].name);
    all_paragraph_styles.push(the_document.paragraphStyleGroups[i].paragraphStyles[b]);

  • gorbon shubbeth says:

    Hm, I tried to visit Thomas’ site today and got multiple malware warnings from Google/Safari. Anyone else encounter this? Any chance the applescript is hosted elsewhere?

  • @Gorbon: Wow, that is bad! I have just emailed Thomas about this; it looks like maybe the site was hacked into.

    I would certainly suggest looking at Formatting Tools from in-tools.com, too, as it is even more powerful.

  • Tom Carlson says:

    Does anyone know where to find Thomas script? The site seams to be down since a long time.

  • SunnyDen says:

    Maybe someone may share the script? The site is still down.

    • Tom and SunnyDen: I found the script and reposted it on our site, as Thomas’s site has been down for a couple of years. Try the link in the blog post again now. I have not tried the script, so I don’t know if it works in any current versions of InDesign!

  • 3rd sister says:

    Wow, thanks so much. You just saved me a lot of time on a 350 page book. I needed each new paragraph after a subhead to be coded with a certain para style. Thomas’ script worked great on InD 5.5.

  • Anand Singh says:

    Hi
    It is not working in InDesing CC 2015.

    Error showing in Line 94, Engine Main, Error 21.

  • Rebecca Davison says:

    This is great, but how do you download it into the scripts panel?

  • Steve Davis says:

    https://github.com/adamjury/fix_pstyle_pairs
    ( updated : FixStylePairs_BrunoHerfst.js )

  • >