Copy link to clipboard
Copied
Hello all! I am writing the script below and am needing some help. I am
wanting to change the language setting in all of the document paragraph
styles to German but when I use the "everyItem" property of paragraphStyles
it does not change any of the style definitions. Could somebody please give
me some help and directions? Thanks a million!
#target indesign
var myDocument = app.activeDocument;
var myStyles = myDocument.paragraphStyles.lastItem();
var myStyle = myStyles;
try{
myStyle.appliedLanguage = "German: 2006 Reform";
alert("The language settings for all of the paragraph styles have
been changed to German: 2006 Reform.")
}
catch(e){}
Hi Awitmer,
The everyItem api will not work in this case because we are not allowed to change the paragraph style None and hence the code will crash and no paragraph style will be edited. You can use a loop and skip the None paragraph style from being edited
for(var i = 0; i < app.activeDocument.paragraphStyles.length; i++)
{
var ps = app.activeDocument.paragraphStyles
if(ps.name == "[No Paragraph Style]")
continue;
else
ps.appliedLanguage = "German: 2006 Reform"
}
-Manan
Copy link to clipboard
Copied
Hi Awitmer,
The everyItem api will not work in this case because we are not allowed to change the paragraph style None and hence the code will crash and no paragraph style will be edited. You can use a loop and skip the None paragraph style from being edited
for(var i = 0; i < app.activeDocument.paragraphStyles.length; i++)
{
var ps = app.activeDocument.paragraphStyles
if(ps.name == "[No Paragraph Style]")
continue;
else
ps.appliedLanguage = "German: 2006 Reform"
}
-Manan
Copy link to clipboard
Copied
Thanks Manan!
This works great! Now I am making a GUI that allows me to choose which language I want to switch to. 🙂
Copy link to clipboard
Copied
Hi Awitmer,
Can you post that once it's done? I could use that very well, but I've not done much with GUIs...
Thanks in advance!
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more