Skip to main content
deckarduk
Inspiring
April 28, 2022
Question

appliedLanguage question

  • April 28, 2022
  • 1 reply
  • 871 views

I'm trying to set an applied language to a paragraph style.

When I use this app.activeDocument.allParagraphStyles[20].appliedLanguage = app.languagesWithVendors.itemByID(81); on it's own the code works fine. When I put it into a function, as shown below, it fails.

Please can someone help and point me in the right direction.

Thank you.

function processThis() {
    for (ii=1; ii<paraStylesToProcess.length; ii++) {
        //alert(paraStylesToProcess[ii])
        listIndex = paraStylesToProcess[ii];
        app.activeDocument.allParagraphStyles[listIndex].appliedLanguage = app.languagesWithVendors.itemByID(81);
    }
w.close();
}
This topic has been closed for replies.

1 reply

rob day
Community Expert
Community Expert
April 28, 2022

Hi @deckarduk , my suggestion to start a new thread probably confused things. Here’s the code I posted in the other thread:

 

var paraStylesToProcess = app.activeDocument.allParagraphStyles
processThis()

function processThis() {
    for (ii=1; ii<paraStylesToProcess.length; ii++) {
        //alert(paraStylesToProcess[ii])
        //listIndex = paraStylesToProcess[ii];
        //app.activeDocument.allParagraphStyles[listIndex].appliedLanguage = app.languagesWithVendors.itemByID(81);
        paraStylesToProcess[ii].appliedLanguage = app.languagesWithVendors.itemByID(81)
    }
    //w.close();
}

 

https://community.adobe.com/t5/indesign-discussions/appliedlanguage-gt-list-of-available-languages/td-p/3832594

deckarduk
deckardukAuthor
Inspiring
April 28, 2022

Hi Rob,

Thanks again for the help and for the code which works for me.

I can see that runs through all the paragraph styles and changes them.

What I'd done elsewhere in my code was create a list of paragraph styles that aren't set to my required language.

I was then trying to use that list of numbers to process the only those paragraph styles.

When I loop through the list of numbers, using an alert dialog, they're all correct.

 

What's odd is that this line of code works on it's own app.activeDocument.allParagraphStyles[20].appliedLanguage = app.languagesWithVendors.itemByID(81); yet when I put it into a function it fails?

 

Thanks again for your help.

 

rob day
Community Expert
Community Expert
April 28, 2022

Without seeing all of your code—it could be allParagraphStyles, which is an array of all the document styles including paragraphStyleGroups, vs. paragraphStyles which is a collection of styles not including paragraphStyleGroups. Collections and Arrays have different methods.

 

 

 

var as = app.activeDocument.allParagraphStyles;
var ps = app.activeDocument.paragraphStyles;

//these might be different
$.writeln(as.length)
$.writeln(ps.count())