Skip to main content
Known Participant
February 23, 2024
Answered

Looking for a script to change Paragraph style case to AllCaps

  • February 23, 2024
  • 2 replies
  • 571 views

Hi!

 

I'm looking for code to add to a script that will change the case of a specific paragraph style to AllCaps. To be clear, not to change all instances to uppercase but to change the case inherent to the style to AllCaps. Thanks in advance for any help!

 

Thanks,

 

Eubha

This topic has been closed for replies.
Correct answer m1b

Hi @EubhaLiath, this is how:

var doc = app.activeDocument;
var myParaStyle = doc.paragraphStyles.itemByName('My Style');

if (myParaStyle.isValid)
    myParaStyle.capitalization = Capitalization.ALL_CAPS;

- Mark 

2 replies

m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
February 23, 2024

Hi @EubhaLiath, this is how:

var doc = app.activeDocument;
var myParaStyle = doc.paragraphStyles.itemByName('My Style');

if (myParaStyle.isValid)
    myParaStyle.capitalization = Capitalization.ALL_CAPS;

- Mark 

Known Participant
February 27, 2024

That's brilliant, thank you! Exactly what I needed. Only small hiccup - it doesn't work if the style is in a style folder and I'm not sure how to alter it to sort that. Any ideas?

Anantha Prabu G
Legend
February 27, 2024

Hi @EubhaLiath 

var doc = app.activeDocument;
var myParaStyle = doc.paragraphStyleGroups.item("My Group").paragraphStyles.itemByName('My Style');

if (myParaStyle.isValid)
    myParaStyle.capitalization = Capitalization.ALL_CAPS;
Thanks,PrabuDesign smarter, faster, and bolder with InDesign scripting.
Mike Witherell
Community Expert
Community Expert
February 23, 2024

Why not make a secondary paragraph style that is set to all caps?

Mike Witherell
Known Participant
February 27, 2024

The styles are linked to export tags so they need to stay the same. Thank you though.