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

How can I modify the color of existing Tags using a script in InDesign?

Contributor ,
Dec 07, 2024 Dec 07, 2024

Copy link to clipboard

Copied

Hello everyone! I have a question to ask.
I have added Tags ABCD in InDesign, and I want to use a script to change the color of these Tags during the operation, to distinguish between the state before and after the operation.
I have reviewed some related materials and found that the color of Tags can only be set when adding an XMLTag, but I can't find a way to modify the color of existing Tags using a script.
I hope someone can guide me.

Thank you all!

TOPICS
Scripting

Views

139

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 Expert , Dec 07, 2024 Dec 07, 2024

Hi @Aprking, I don't understand what's going wrong. I just tried it here and it worked, for example:

app.activeDocument.xmlTags[1].tagColor = [200, 50, 255];

Does this work for you?

- Mark

Votes

Translate

Translate
Community Expert ,
Dec 07, 2024 Dec 07, 2024

Copy link to clipboard

Copied

Hi @Aprking, I don't understand what's going wrong. I just tried it here and it worked, for example:

app.activeDocument.xmlTags[1].tagColor = [200, 50, 255];

Does this work for you?

- Mark

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
Contributor ,
Dec 07, 2024 Dec 07, 2024

Copy link to clipboard

Copied

Thank you to @m1b  for your help. I have successfully completed the code to change the tagColor.

The previous failure was caused by other errors in the code. Thanks again!

 

 

var doc = app.activeDocument; 
var xmlTags = doc.xmlTags;

for (var i = 0; i < xmlTags.length; i++) {
    if (xmlTags[i].name == "A") {  
        xmlTags[i].tagColor = 1766025324;  
        break;  
    }
}

 

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 ,
Dec 07, 2024 Dec 07, 2024

Copy link to clipboard

Copied

LATEST

You're welcome. Hope your script goes great. 

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