Skip to main content
dublove
Legend
Nov 22, 2026 1:57 PM UTC
Answered

Is there a 'table of contents styles loading command' similar to importing paragraph styles?

Hello everyone.

I saw this, is there any code to import directory styles?

app.activeDocument.importStyles(ImportFormat.PARAGRAPH_STYLES_FORMAT, File(styPath), GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE);

 

    Eugene TysonCorrect answer
    Community Expert
    Nov 22, 2026 2:14 PM UTC

    Yes, you can use the same importStyles() method for Table of Contents styles.

    Just replace ImportFormat.PARAGRAPH_STYLES_FORMAT with ImportFormat.TOC_STYLES_FORMAT.

    app.activeDocument.importStyles(
    ImportFormat.TOC_STYLES_FORMAT,
    File(styPath),
    GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE
    );

    This imports the TOC style definitions from the source InDesign document, overwriting existing TOC styles with matching names.

    One thing to watch out for is that TOC styles reference paragraph styles, so make sure the corresponding paragraph styles exist in the destination document. Otherwise, you may need to import those separately or adjust the imported TOC style.

    2 replies

    Eugene TysonCommunity ExpertCorrect answer
    Community Expert
    Nov 22, 2026 2:14 PM UTC

    Yes, you can use the same importStyles() method for Table of Contents styles.

    Just replace ImportFormat.PARAGRAPH_STYLES_FORMAT with ImportFormat.TOC_STYLES_FORMAT.

    app.activeDocument.importStyles(
    ImportFormat.TOC_STYLES_FORMAT,
    File(styPath),
    GlobalClashResolutionStrategy.LOAD_ALL_WITH_OVERWRITE
    );

    This imports the TOC style definitions from the source InDesign document, overwriting existing TOC styles with matching names.

    One thing to watch out for is that TOC styles reference paragraph styles, so make sure the corresponding paragraph styles exist in the destination document. Otherwise, you may need to import those separately or adjust the imported TOC style.

    Translate
    dublove
    dubloveAuthor
    Legend
    Nov 22, 2026 4:12 PM UTC

    Thank you very much.

    I found it by looking up the ImportFormat in the manual.
    I have tried to find other keywords, but have not been successful.

    Translate