doc = app.activeDocument;
var srcPath = doc.path +"/codes.txt" // put the codes.txt in the same folder as the .Ai file
var codeFile = new File (srcPath);
var openF = codeFile.open ("r");
if (openF) {
var codeLines = new Array ();
var codes = codeFile.read();
var codeLines = codes.split("\n"); // split file by line, if you have a comma delimted file put "," instead of "\n"
codeFile.close();
}
alert(codeLines.length +" Codes in your Document and " +"\n" + putCode.length +" textframes to replace")
var putCode = doc.layers[0].textFrames // will put the codes in all the text frames of the top layer
for (var i = 0;i<putCode.length;i++) { // starts on line 1 of the code.txt
putCode[i].contents = codeLines[i];
}