Illustrator Find And Replace
Hi there,
Can anybody tell me if it's possible to JavaScript Illustrators Find And Replace text function?
I know it's possible in InDesign but I can't find anything for Illustrator.
Many Thanks,
Nik
Hi there,
Can anybody tell me if it's possible to JavaScript Illustrators Find And Replace text function?
I know it's possible in InDesign but I can't find anything for Illustrator.
Many Thanks,
Nik
Hi Nik, no need to dig down to words, we can search the whole textFrame.contents. Here's a working sample
var active_doc = app.activeDocument;
var search_string = /blah/gi; // g for global search, remove i to make a case sensitive search
var replace_string = "lalala";
var text_frames = active_doc.textFrames;
if (text_frames.length > 0)
{
for (var i = 0 ; i < text_frames.length; i++)
{
var this_text_frame = text_frames;
var new_string = this_text_frame.contents.replace(search_string, replace_string);
if (new_string != this_text_frame.contents)
{
this_text_frame.contents = new_string;
}
}
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.