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

Script works in Indesign 2020 but not in 2021 or 2022

Community Beginner ,
Mar 31, 2022 Mar 31, 2022

Copy link to clipboard

Copied

I have the following that works just fine in Indesign 2020 and eariler, but I can not get it to work in anything later. Any one know how to get it working in 2022?

 

var myColor = app.documents[0].colors.itemByName("red");

// Is it really there?

if( myColor.isValid )

{

     myColor.properties =

{

          model : ColorModel.SPOT ,

          space : ColorSpace.CMYK ,

          colorValue : [0,100,80,0]

     }

}

TOPICS
Scripting

Views

195

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

Community Beginner , Apr 01, 2022 Apr 01, 2022

I appriciate everyones help.

After learning here that it works in 17.2 I tried it on a friends Mac and it also worked.

Turns out I had to delete my Indesign preferences to get it going on mine.

 

Thanks again

Paul

Votes

Translate

Translate
Enthusiast ,
Mar 31, 2022 Mar 31, 2022

Copy link to clipboard

Copied

Hi,
works as it should in 17.1 – assuming you already have a swatch called "red" in your document – otherwise your snippet does nothing (as expected).

Do you get an error message?

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 Beginner ,
Mar 31, 2022 Mar 31, 2022

Copy link to clipboard

Copied

Sorry, I should have been more precise in what "does not work"

If I have a swatch red defined with a color value of 0,85,85,0

and run the script, it should change the color value of the red swatch to 0,100,80,0

It does this in 15.1.4, but does not in 17.2.

And I do not get an error at all.

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 ,
Mar 31, 2022 Mar 31, 2022

Copy link to clipboard

Copied

Hi paul.abney@emprinting.com, I can confirm it works as expected in Indesign 17.2 MacOS.

 

A clue could be that you don't get an error. This might be because your code doesn't do anything if the color is invalid. See slightly modified script below. Also note that the colorName is case sensitive.

- Mark

 

var colorName = "Red";
var myColor = app.documents[0].colors.itemByName(colorName);
// Is it really there?
if (myColor.isValid) {
    myColor.properties = {
        model: ColorModel.SPOT,
        space: ColorSpace.CMYK,
        colorValue: [0, 100, 80, 0]
    }
}
else {
    // color not valid, probably not in document
    alert('Could not find color "' + colorName + '".');
}

 

 

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 ,
Mar 31, 2022 Mar 31, 2022

Copy link to clipboard

Copied

Hi Paul,

I can see this as well. But only if there is no named color with "red" in its name.

Check the exact name of your color "red" in the Swatches panel of your document.

Perhaps it's "Red" with a capital "R" and not "red".

Hm. Or the name of your color starts with "red", but has a trailing white space after the "d" like "red ".

 

Regards,
Uwe Laubender

( ACP )

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 ,
Mar 31, 2022 Mar 31, 2022

Copy link to clipboard

Copied

"It does this in 15.1.4, but does not in 17.2."

 

Please provide your InDesign test documents for each of the versions.

Put them on Dropbox or a similar service and post the download link.

 

Thanks,
Uwe Laubender

( ACP )

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 Beginner ,
Apr 01, 2022 Apr 01, 2022

Copy link to clipboard

Copied

LATEST

I appriciate everyones help.

After learning here that it works in 17.2 I tried it on a friends Mac and it also worked.

Turns out I had to delete my Indesign preferences to get it going on mine.

 

Thanks again

Paul

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