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

Adding Paragraph Style Properties Causing Errors

Enthusiast ,
Sep 11, 2022 Sep 11, 2022

Copy link to clipboard

Copied

Hi Experts, im trying to add paragraph styles via scripting, it works fine but when i add (next style) or (based on) it cause error (invalid parameter) i can set off (next style) in first one! and let based on work or reverese adding the styles but i think there are better solution , i think this happened because the script not adding the paragraph styles yet!, but how to avoid this problem ? and thanks a lot in advance , here is the code :

 

//Adding Paragraph Styles by Script
var myDoc = app.activeDocument;
    
    //Adding First Style
    var myParagraphPoemStyle1 = myDoc.paragraphStyles.item("Style1" );
    !myParagraphPoemStyle1.isValid && myParagraphPoemStyle1 = myDoc.paragraphStyles.add({
        name: "Style1",
        nextStyle: myDoc.paragraphStyles.item("Style2"),        
    })

     //Adding Next Style
    var myParagraphPoemStyle2 = myDoc.paragraphStyles.item("Style2" );
    !myParagraphPoemStyle2.isValid && myParagraphPoemStyle2 = myDoc.paragraphStyles.add({
        name: "Style2",
        basedOn : myDoc.paragraphStyles.item("Style1"),  
    })

 

the error message :

Invalid Parameters.jpg

Best
M.Hasanain
TOPICS
Scripting

Views

50

Likes

Translate

Translate

Report

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

Enthusiast , Sep 12, 2022 Sep 12, 2022

i found a solution !, i can assign it after creating, it seem that no way to assign it during creating! :

 

 myParagraphPoemStyle1.nextStyle = myParagraphPoemStyle2;   
 myParagraphPoemStyle2.basedOn = myParagraphPoemStyle1;

 

 

Likes

Translate

Translate
Enthusiast ,
Sep 12, 2022 Sep 12, 2022

Copy link to clipboard

Copied

LATEST

i found a solution !, i can assign it after creating, it seem that no way to assign it during creating! :

 

 myParagraphPoemStyle1.nextStyle = myParagraphPoemStyle2;   
 myParagraphPoemStyle2.basedOn = myParagraphPoemStyle1;

 

 

Best
M.Hasanain

Likes

Translate

Translate

Report

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