Skip to main content
gregorym17975653
Known Participant
December 4, 2019
Answered

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

  • December 4, 2019
  • 1 reply
  • 2035 views

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 has been closed for replies.
Correct answer xxxxxxxxxxxxxxxxxxxxyyyy

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.

1 reply

xxxxxxxxxxxxxxxxxxxxyyyy
Participating Frequently
December 4, 2019

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.

gregorym17975653
Known Participant
December 4, 2019

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

Community Expert
December 5, 2019

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

-Manan