Copy link to clipboard
Copied
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
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thanks for your help. What about character style? Are they working on the same way?
Copy link to clipboard
Copied
yes, use the same concept for applying character styles
Copy link to clipboard
Copied
Thank you i will try it
Find more inspiration, events, and resources on the new Adobe Community
Explore Now