Skip to main content
October 3, 2011
Question

Using Script to Apply ParagraphStyle

  • October 3, 2011
  • 2 replies
  • 540 views

I'm using a script to apply a style that formats the text in an active document...such as the font style and size and it indents the first line of every paragraph.

When I run this script it only applies the style on the first paragraph and stops.

Here is the script:

var myDocument = app.activeDocument;

var myParagraphStyle = myDocument.paragraphStyles.item("My Paragraph Style");

myDocument.pages.item(0).textFrames.item(0).paragraphs.item(0).appliedParagraphStyle = myParagraphStyle;

Thank you in advance for any help on this.

This topic has been closed for replies.

2 replies

csm_phil
Legend
October 3, 2011

Hi North,

Try this below JS Code.

var myDoc = app.activeDocument;

myDoc.pages[0].textFrames[0].paragraphs[0].appliedParagraphStyle = myDoc.paragraphStyles.itemByName("My P Style");

thx

csm_phil

TᴀW
Legend
October 3, 2011
id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators