Thanks for coming to InDesignSecrets.com, the world's #1 resource for all things InDesign!

Find Change the Next Paragraph Style with a Script

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).

Tags
Related Articles
Comments

16 Comments on “Find Change the Next Paragraph Style with a Script

  1. 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… :)

  2. 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.

  3. 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.

  4. 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

  5. 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.

  6. 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?

  7. 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

  8. 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]);

  9. 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?

  10. @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 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!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>