Skip to main content
gregorym17975653
Known Participant
Dec 4, 2019 6:39 PM UTC
Answered

Need to change predefined paragraph style items in multiple Indesign files with javascript ....

Hi,
I need to change a predefined paragraph style in 50 to 75 Indesign files. The paragraph style name is called “3. text”.  Can someone help me wirte a simple javascript line to change the applied font name “Times New Roman” and fontstyle “Regular” to font name “YaleNew” and fontstyle “Roman”?

Thanks in advance for your assistance.
-Greg

This topic is closed to new replies. Start a new post to keep the conversation going.
xxxxxxxxxxxxxxxxxxxxyyyy
Participating Frequently
Dec 4, 2019 9:52 PM UTC

Hi,

if a one liner is simply enough than this should do the trick

app.activeDocument.paragraphStyles.itemByName("3. text").appliedFont = "YaleNew\tRoman";

It will only change the font of the paragraph style 3. text in the currently active document.

6 replies

xxxxxxxxxxxxxxxxxxxxyyyy
Participating Frequently
Dec 4, 2019 9:52 PM UTC

Hi,

if a one liner is simply enough than this should do the trick

app.activeDocument.paragraphStyles.itemByName("3. text").appliedFont = "YaleNew\tRoman";

It will only change the font of the paragraph style 3. text in the currently active document.

Translate
gregorym17975653
Known Participant
Dec 4, 2019 11:28 PM UTC

Thanks Crazy Panda for your response and YES it does exactly what I need! 

Now to make this script complete, can you give me another javascript one liner that will change the capitalization to Open Type Small Caps for character style called "3b. text, cap" ?

I attempted the following with no success:

app.activeDocument.characterStyles.itemByName("3b. text, cap").appliedFont = "YaleNew\tRoman", Capitalization.CAP_TO_SMALL_CAP;



-Greg

Translate
Community Expert
Dec 5, 2019 5:38 AM UTC

For capitalization you need to set the capitalization property as follows

 

app.activeDocument.characterStyles.itemByName("3b. text, cap").capitalization = Capitalization.CAP_TO_SMALL_CAP

 

 

For a complete list of properties and methods for character styles you can check the following link

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#CharacterStyle.html

 

-Manan

Translate
-Manan