Scripting: Stop function from running on all open documents
I have this script that will do a word replace on all text in a document (changes all words to a single word you type in). Problem is, this script will run on all of my open documents instead of the currently active document. Could I get some help editing this please? I've tried idoc = app.Activedocument but it breaks it. Thanks.
#target Illustrator
function Fontcheck() {
var idoc, tframes, i, tframe, new_string, counter = 0;
var replace_string = prompt("Word","");
for (var a = 0; a < app.documents.length; a++) {
idoc = app.documents;
tframes = idoc[a].textFrames;
for (i = 0; i < tframes.length; i++) {
tframe = tframes[i];
new_string = tframe.contents.replace(tframe.contents, replace_string);
if (new_string != tframe.contents) {
tframe.contents = new_string;
counter++;
}
}
}
};
Fontcheck();
