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
  • 2026 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 crazyPanda

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

crazyPanda
crazyPandaCorrect answer
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

gregorym17975653
Known Participant
December 5, 2019

if you want to change both the font and the capitalization with one line:

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

 


Exactly what I needed, thanks! I also appreciate the "CharacterStyle ExtendScriptAPL" link, however, I'm having difficult with some of the syntax.

For example, I tried to include OpenTypeFigureStyle.PROPORTIONAL_OLDSTYLE as follows:

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


But this does not work. Can you help explain what I'm doing incorrectly?

-Greg