• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Apply custom Paragraph Style to [No Paragraph]

Participant ,
Jan 11, 2017 Jan 11, 2017

Copy link to clipboard

Copied

Hi all,

I am looking for examples how to apply own Body Text Paragraph Style to [No Paragraph] Style. The Body Text is a part of Group EN:

Screen Shot 2017-01-11 at 13.52.06.png

Normally I would use Find/Change dialog but I believe there is a better way with scripting?

Screen Shot 2017-01-11 at 13.54.27.png

TOPICS
Scripting

Views

748

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 11, 2017 Jan 11, 2017

Copy link to clipboard

Copied

Hi,

var myDoc = app.activeDocument,

myParaStylesGroup = myDoc.paragraphStyleGroups.item('EN'),

myParaStyle = myParaStylesGroup.paragraphStyles.item('Body Text');

app.findGrepPreferences = app.changeGrepPreferences = null;

app.findGrepPreferences.appliedParagraphStyle = myDoc.paragraphStyles[0];

app.changeGrepPreferences.appliedParagraphStyle = myParaStyle;

myDoc.changeGrep();

app.findGrepPreferences = app.changeGrepPreferences = null;

(^/)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 12, 2017 Jan 12, 2017

Copy link to clipboard

Copied

Works!

I was tinkering :

try{

app.activeDocument.textFrames[0].insertionPoints[0].select();

var pStyleGroup = app.activeDocument.paragraphStyleGroups.itemByName('EN');

var titleStyle = pStyleGroup.paragraphStyles.itemByName('Body Text')

app.activeDocument.paragraphs[0].applyParagraphStyle (app.activeDocument.paragraphStyles.item ("Body Text", true));

}catch(e){};

How about 'try': if for instance my Paragraph style will be different and I don't wanna see the error thrown by JavaScript? (will manually apply the style with that different name afterwards)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 12, 2017 Jan 12, 2017

Copy link to clipboard

Copied

Pete Stan wrote:

… Normally I would use Find/Change dialog but I believe there is a better way with scripting?

Hi Pete,

why do you believe that scripting is a better way?
Would you like to add something to the process by scripting what Find/Change cannot do?

Regards,
Uwe

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 12, 2017 Jan 12, 2017

Copy link to clipboard

Copied

LATEST

Yes, To make my life easier!

I have already a script that places a Word Document, auto-flows on A4, runs Jongware's PrepText, asks me to load the styles and now I can skip the step I was performing manually

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines