4 Replies Latest reply on Jan 12, 2010 12:01 AM by Roger Sawhill

    [CS3 AS] Replace color

      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?
        • 1. Re: [CS3 AS] Replace color
          sstanleyau Level 4
          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>
          • 2. Re: [CS3 AS] Replace color
            Level 1
            Whoops! forgot the "tell document 1". Thanks!
            • 3. Re: [CS3 AS] Replace color
              Level 1
              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.
              • 4. Re: [CS3 AS] Replace color
                Roger Sawhill

                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