Search code examples
applescriptadobe-indesign

Clearing character style overrides when deleting styles in Indesign using Applescript


I'm converting 400+ documents to a new layout format.

I'm trying to delete a character style and remove the formatting for it. (AKA, delete a character style with the checkbox checked).

Here's my code:

delete character style "Exhibit Number" of character style group "Exhibit Styles" 
replacing with character style "[None]"

It works to delete the character style, but it doesn't remove the formatting. Random stabs in the dark, like appending without formatting, without Preserve Formatting, without Overrides, and with "Preserve Formatting" = false triggers an error.

Is there a way of doing this via script? (Can I do with properties{None}, by setting a preference to not preserve overrides, or some variation therein?)


Solution

  • "[None]" is not a character style per say. It's more of a link to style breaker. So any of the overrides are not removed. A solution would be to create a dummy "None" character style based on [None] and then eventually ste to [None] character style.

    In JavaScript this would be:

    //Removing overrides
    text.clearOverrides();
    //Setting to dummy None
    text.appliedCharacterStyle = app.activeDocument.characterStyles.item("My Dummy Sans");
    //Now breaking link to a character style i.e. applying "[None]";
    text.appliedCharacterStyle = app.activeDocument.characterStyles[0];