Skip to main content
Inspiring
November 26, 2014
Answered

How to map para style by script

  • November 26, 2014
  • 1 reply
  • 1068 views

Hi

My indesign file has already some Group style, when I try to flow the XML file in Indesign that time same style of paragraph are not mapped with automatically. FYI

Here 'TXT' style is already defined in 'Chapters' Group style (see Part A). After flowing again 'TXT' (see Part B) is coming in without mapping.

Now I want to map the 'Part B' style with 'Part A' is this possible by script?

This topic has been closed for replies.
Correct answer BEGINNER_X

Hi Hasvi,

May the below code is useful, please test in your end.

Thanks vandy...

_mappingStyle("TXT", "Chapters", "TXT")

_mappingStyle("TXT1", "Chapters", "TXT1")

function _mappingStyle(findStyle, changeGroup, changeStyle)

{

    app.findGrepPreferences = app.changeGrepPreferences = null; 

    app.findGrepPreferences.appliedParagraphStyle = findStyle; 

    app.changeGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyleGroups.item(changeGroup).paragraphStyles.item(changeStyle);  

    app.activeDocument.changeGrep();   

    app.findGrepPreferences = app.changeGrepPreferences = null; 

    }

Regards

Siraj

1 reply

Legend
November 26, 2014

Try this,

app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences.appliedParagraphStyle = "TXT";

app.changeGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyleGroups.item("Chapters").paragraphStyles.item("TXT");

app.activeDocument.changeGrep(); 

app.findGrepPreferences = app.changeGrepPreferences = null;

Vandy

hasviAuthor
Inspiring
November 26, 2014

Hi vandy

thanks, but if I want to add more style names in existing script means, how can I add the below styles

TXI, H1, H2, EXT...

thanks

BEGINNER_X
BEGINNER_XCorrect answer
Legend
November 26, 2014

Hi Hasvi,

May the below code is useful, please test in your end.

Thanks vandy...

_mappingStyle("TXT", "Chapters", "TXT")

_mappingStyle("TXT1", "Chapters", "TXT1")

function _mappingStyle(findStyle, changeGroup, changeStyle)

{

    app.findGrepPreferences = app.changeGrepPreferences = null; 

    app.findGrepPreferences.appliedParagraphStyle = findStyle; 

    app.changeGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyleGroups.item(changeGroup).paragraphStyles.item(changeStyle);  

    app.activeDocument.changeGrep();   

    app.findGrepPreferences = app.changeGrepPreferences = null; 

    }

Regards

Siraj