Skip to main content
Participant
March 21, 2017
Question

Adobe Illustrator CC Script to export ase swatches to excel

  • March 21, 2017
  • 3 replies
  • 4497 views

Looking for some way to have a script run in Adobe Illustrator CC that will export ase swatches into an excel file that outputs the color name and CMYK values into a sheet.

There was a previous post written about this but it was for CS InDesign. convert ase swatches to excel

Thank you in advance, hope to find an answer!

This topic has been closed for replies.

3 replies

Participant
March 22, 2017

I figured it out. Can't have the swatches set to global. Once I unchecked global on all swatches it worked. Thank you!!

Qwertyfly___
Legend
March 23, 2017

I played with this idea for someone last year.

can't remember if it deals with global swatches or not, but it should.

Export of color values to Excel

Silly-V
Legend
March 21, 2017

Hi, this script here will start you off on Process swatches!

#target illustrator

function test(){

     var doc = app.activeDocument, sw, rowsArr = [["Name"]], recordArr = [];

     if(doc.documentColorSpace == DocumentColorSpace.CMYK){

          rowsArr[0] = rowsArr[0].concat(["C","M","Y","K"]);

     } else {

          rowsArr[0] = rowsArr[0].concat(["R","G","B"]);

     }

     for(var i=0; i<doc.swatches.length; i++){

          sw = doc.swatches;

          recordArr = [];

          if(sw.name == "[None]" || sw.name == "[Registration]" ||

               (sw.color.typename != "CMYKColor" && sw.color.typename != "RGBColor")){

               continue;

          }

          recordArr.push(sw.name);

          if(doc.documentColorSpace == DocumentColorSpace.CMYK){

               recordArr = recordArr.concat([sw.color.cyan, sw.color.magenta, sw.color.yellow, sw.color.black]);

          } else {

               recordArr = recordArr.concat([sw.color.red, sw.color.green, sw.color.blue]);

          }

          rowsArr.push(recordArr);

     };

     var csvFile = File("~/Desktop/swatches-from-script.csv");

     csvFile.open('w');

     csvFile.write(rowsArr.join("\n"));

     csvFile.close();

};

test();

Participant
March 22, 2017

Thank you for this!

It worked and then stopped working...

For some reason when I run the script then open the excel file it gives me a file like the below without any swatch values. The file I'm running the script on has lots of swatches.

NameCMYK
Silly-V
Legend
March 22, 2017

This script only does process swatches, do you have spot color swatches in your document?

Mike_Gondek10189183
Community Expert
Community Expert
March 21, 2017

You should have better luck at this forum.

Illustrator Scripting