Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Make change to all Document Styles using a script

Participant ,
Sep 28, 2018 Sep 28, 2018

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){}

TOPICS
Scripting
782
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 28, 2018 Sep 28, 2018

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

Translate
Community Expert ,
Sep 28, 2018 Sep 28, 2018

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Oct 01, 2018 Oct 01, 2018

Thanks Manan!

This works great! Now I am making a GUI that allows me to choose which language I want to switch to. 🙂

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 02, 2018 Oct 02, 2018
LATEST

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines