Skip to main content
Inspiring
April 22, 2023
Answered

How to find and change tint value of "black" color swatch including masterPage contents

  • April 22, 2023
  • 2 replies
  • 595 views

I was trying to find and change tint value of black color from '60' to '70' .Below code was working fine with contents of  page items but the changes were not reflected in masterPage contents. So i tried as like below but this was working for me sometimes in indesign 2021 but it was not working in any other indesign versions like 2019 or 2022. Please help me with this! 

FindChangeTextOption.includeMasterPages = true; 
app.findTextPreferences = app.changeTextPreferences = NothingEnum.NOTHING;
app.findTextPreferences.fillColor = 'Black';
app.findTextPreferences.fillTint = 60;
var foundItems = app.activeDocument.findText(true);
app.findTextPreferences = app.changeTextPreferences = NothingEnum.NOTHING;

for (var f = 0; f < foundItems.length; f++) {
    foundItems[f].fillTint = 70;
}

 

This topic has been closed for replies.
Correct answer rob day

Hi @Karthik SG , Try this:

 

app.findTextPreferences = app.changeTextPreferences = app.findChangeTextOptions = null;
app.findTextPreferences.properties = {fillColor:"Black", fillTint:60}   
app.findChangeTextOptions.properties = { 
        includeHiddenLayers:true, 
        includeLockedLayersForFind:true, 
        includeLockedStoriesForFind:true, 
        includeMasterPages:true} 
var foundItems = app.activeDocument.findText()

for (var f = 0; f < foundItems.length; f++) {
    foundItems[f].fillTint = 70;
}

2 replies

Community Expert
April 25, 2023

HI @Karthik SG,

Look at the code given by @rob day it seems you missed setting the property to search in masterpages which is resulting in the behaviour you see, To account for cases where previously you found your script to work sometimes might be attributed to the fact that this option of searching in masterpages when swithced on via UI would result in the search to find masterpage items. Since you don't set this property using your code it is dependent upon what has been done by someone on the UI

-Manan

-Manan
Inspiring
April 25, 2023

Yes Manan I understood, Now by using the code given by @rob day it was working fine. Thanks for the response and reply 

rob day
Community Expert
rob dayCommunity ExpertCorrect answer
Community Expert
April 22, 2023

Hi @Karthik SG , Try this:

 

app.findTextPreferences = app.changeTextPreferences = app.findChangeTextOptions = null;
app.findTextPreferences.properties = {fillColor:"Black", fillTint:60}   
app.findChangeTextOptions.properties = { 
        includeHiddenLayers:true, 
        includeLockedLayersForFind:true, 
        includeLockedStoriesForFind:true, 
        includeMasterPages:true} 
var foundItems = app.activeDocument.findText()

for (var f = 0; f < foundItems.length; f++) {
    foundItems[f].fillTint = 70;
}