Reply To: Using different colors for the same styles in chapters of a book

Home Page / Forums / General InDesign Topics (CLOSED) / Using different colors for the same styles in chapters of a book / Reply To: Using different colors for the same styles in chapters of a book

#74606

Hi all,
I had the same question and achieved it thanks to a script, but It will work only on Mac since I wrote it in AppleScript (I don’t know Javascript, sorry…).

First, create a swatch whose name would be consistent across all documents in the book and relevant like “Chapter_color”. This swatch will be applied to anything related to the chapter, like titles, cell’s fill colors, etc.
It’s essential to give it a name.
If you sync it normally, the values of the swatch will be overwritten to match the values of the source file in the book.

So the workaround is not to sync the book with InDesign directly, but let the script do it instead.
The script “saves” the values of each document’s chapter color in a duplicated swatch, then re-create the swatch with these values.
I didn’t find anything else to achieve it.

Here is the script :

————————————————————————————————
[code]
set AppleScript’s text item delimiters to ""

set theChapterColorName to "COULEUR-CHAPITRE"
set theValidatedChapterColorName to theChapterColorName & "-OK"

tell application id "com.adobe.InDesign"
activate
try
set myBook to active book
on error
display dialog "Aucun livre n’est ouvert." with icon 0
return
end try

set myBook_Files to object reference of every book content of active book

set theSourceINDD to style source document of myBook
set theSourceINDD_file to (full name of theSourceINDD) as string –path
set myBook_list to {}
repeat with myBook_File in myBook_Files
set myBook_File_path to (full name of myBook_File) as string
if myBook_File_path is not theSourceINDD_file then
set myBook_list’s end to myBook_File_path
end if
end repeat

repeat with myBook_File in myBook_list –open all files except the style source document
open file myBook_File
tell document 1
set theChapterSwatch to item 1 of (every swatch whose name is theChapterColorName)
set theChapterSwatch_properties to properties of theChapterSwatch
set newProperties to {name:theValidatedChapterColorName} & theChapterSwatch_properties
set theReplacedColor to make new color with properties newProperties

end tell
end repeat

synchronize myBook

repeat with myBook_File in myBook_list –open all files except the style source document
open file myBook_File
tell document 1
set theChapterSwatch to item 1 of (every swatch whose name is theValidatedChapterColorName)
set theBadSwatch to item 1 of (every swatch whose name is theChapterColorName)
theChapterSwatch merge with theBadSwatch
set name of theChapterSwatch to theChapterColorName
end tell
end repeat

end tell
[/code]

————————————————————————————————

Of course it’s better if you know a bit of AppleScript…

This article was last modified on April 13, 2015

Comments (0)

Loading comments...