Skip to main content
Participating Frequently
February 3, 2009
Question

[CS3 AS] Replace color

  • February 3, 2009
  • 3 replies
  • 552 views
Hi - new to applescript.

I want to replace "White" with the Paper color
I'm missing something - why isn't this working for me?:

tell application "Adobe InDesign CS3"
delete swatch "White" replacing with swatch "Paper"
end tell

Also, it might be "WHITE", "White" or "white" is there as way to do that in one step?
This topic has been closed for replies.

3 replies

_Kermy_Author
Participating Frequently
February 5, 2009
Your code worked out swell!
I did change this line:
if item i of colorNames = "White" then
to:
if item i of colorNames contains "White" then
This allowed me to get rid of swatches like "White copy" or "White 2" as well.
Known Participant
January 12, 2010

Kermy, would it be possible for you to post the script you wrote? I'd love to use it a s a basis for a color replacement need I have and I'm really rusty at this scripting thing.

Any help would be greatly appreciated.

Roger

_Kermy_Author
Participating Frequently
February 4, 2009
Whoops! forgot the "tell document 1". Thanks!
Inspiring
February 3, 2009
On 4/2/09 8:07 AM, "Kermy" <member@adobeforums.com> wrote:<br /><br />> tell application "Adobe InDesign CS3"<br />> delete swatch "White" replacing with swatch "Paper"<br />> end tell <br /><br />This is targetted at the application -- if you want to do it in a document,<br />you need to insert "tell document 1".<br />> <br />> Also, it might be "WHITE", "White" or "white" is there as way to do that in<br />> one step? <br /><br />You'll need to do something like get the name of every swatch, then loop<br />through doing a comparison inside an "ignoring case" construct. Something<br />like this:<br /><br />tell application "Adobe InDesign CS3"<br /> tell document 1<br /> set colorNames to name of swatches whose name is not ""<br /> ignoring case<br /> repeat with i from 1 to count of colorNames<br /> if item i of colorNames = "White" then<br /> delete swatch (item i of colorNames) replacing with<br />swatch "Paper"<br /> end if<br /> end repeat<br /> end ignoring<br /> end tell<br />end tell<br /><br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>