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

Script to change overprintFill of all paragraph styles in document

New Here ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

I'm a bit lost with scripting - got into it a few years ago, but have forgotten most of what I learned. I'm trying to make a script that will turn on the 'overprint fill' setting in the charactor colour panel of all the paragraph styles in my document. This is what I've come up with, but it's not working:

 

var allParagraphStyles = app.activeDocument.paragraphStyles;
for (i=1; i<allParagraphStyles.length; i++)
{
allParagraphStyles[i].overprintFill = true;
}

 

Would be great if someone could fix this for me so it works - presumably it doesn't need to be a very long script.

Thanks

TOPICS
Scripting

Views

729

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

Advocate , May 29, 2020 May 29, 2020

Try this code sample:

////////////////////////////////////////

var myDoc = app.documents[0];
applyOverPrint(myDoc);
for(var
i = 0; i < myDoc.paragraphStyleGroups.length; i++){
    applyOverPrint(myDoc.paragraphStyleGroups[i]);
    }
//////////////////////////////////////////
function
applyOverPrint(object){
    for(var
i = 0; i < object.paragraphStyles.length; i++){
        try{
            object.paragraphStyles[i].overprintFill = true;
            }
        catch(
e){}
        }
    }

//////////////////////

...

Votes

Translate

Translate
Advocate ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

Try this code sample:

////////////////////////////////////////

var myDoc = app.documents[0];
applyOverPrint(myDoc);
for(var
i = 0; i < myDoc.paragraphStyleGroups.length; i++){
    applyOverPrint(myDoc.paragraphStyleGroups[i]);
    }
//////////////////////////////////////////
function
applyOverPrint(object){
    for(var
i = 0; i < object.paragraphStyles.length; i++){
        try{
            object.paragraphStyles[i].overprintFill = true;
            }
        catch(
e){}
        }
    }

////////////////////////////////////////

Best

Sunil

Votes

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
New Here ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

That's brilliant, thanks a million Sunil - it works! You've saved me lots of time.

Hope you have a great day.

Cheers

Simon

Votes

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
Community Expert ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

Hi Simon,

you say: "This is what I've come up with, but it's not working:"

What exactly is not working? Are you facing error messages? Will the value change for some styles and not for others? Do other things happen you did not anticipate?

 

"it's not working" simply is not a sufficient description of your issue.

 

Thanks,
Uwe Laubender

( ACP )

 

// EDITED

Votes

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
New Here ,
May 29, 2020 May 29, 2020

Copy link to clipboard

Copied

LATEST

Ok, thanks, got my answer above, but will keep your feedback in mind for next time.

Cheers

Simon

Votes

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