Skip to main content
Participant
June 10, 2025
Answered

Use of currentParagraph.paragraphStyle with JSX

  • June 10, 2025
  • 1 reply
  • 300 views

Hi, I try to change the paragraph style of a text using this function in jsx : currentParagraph.paragraphStyle = styleToApply; 

 

the style exists and no error appears but nothin happend. Somebody know why? I made a lot of tests during hours but i can't find the issue!

 

Thanks in advance.

 

Ludovic Schmidt

Correct answer CarlosCanto

The syntax you're using is incorrect. You have to supply the paragraph to the paragraph style.

 

var idoc = app.activeDocument;

var myPara = idoc.paragraphStyles["myPara"]; // paragraph style name

var para0 = selection[0].textRange.paragraphs[0]; // selected text frame first paragraph 

myPara.applyTo(para0, true); // apply paragraph style to supplied paragraph

1 reply

CarlosCanto
Community Expert
CarlosCantoCommunity ExpertCorrect answer
Community Expert
June 10, 2025

The syntax you're using is incorrect. You have to supply the paragraph to the paragraph style.

 

var idoc = app.activeDocument;

var myPara = idoc.paragraphStyles["myPara"]; // paragraph style name

var para0 = selection[0].textRange.paragraphs[0]; // selected text frame first paragraph 

myPara.applyTo(para0, true); // apply paragraph style to supplied paragraph
Participant
June 11, 2025

Thanks for your help. What about character style? Are they working on the same way?

CarlosCanto
Community Expert
Community Expert
June 12, 2025

yes, use the same concept for applying character styles