Skip to content

Instantly share code, notes, and snippets.

@v-zhuravlev
Created June 1, 2018 12:23
Show Gist options
  • Save v-zhuravlev/fda7177029360ffa1ca937d9bcc0f3b7 to your computer and use it in GitHub Desktop.
Save v-zhuravlev/fda7177029360ffa1ca937d9bcc0f3b7 to your computer and use it in GitHub Desktop.
color boxes in InDesign with js
if (parseFloat(app.version) > 6)
main();
else
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Color Textboxes Based on Word");
function main() {
var red = app.activeDocument.colors.itemByName("RGB Red");
var blue = app.activeDocument.colors.itemByName("RGB Blue");
var sel = app.selection;
for(s=0;s<sel.length;s++){
var cont = sel[s].parentStory.words
for(w=0;w<cont.length;w++){
//if statement will need to be copy/pasted for each additional word formatting
if(cont[w].contents.toUpperCase() == "EVP"){
sel[s].fillColor = red;
}
if(cont[w].contents.toUpperCase() == "DEAL"){
sel[s].fillColor = blue;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment