Skip to main content
jeremy0013
Inspiring
October 23, 2015
Question

Select all same text

  • October 23, 2015
  • 3 replies
  • 3089 views

How would I go about selecting all the same text?  i.e. getByName("99999")? I am trying to select all text fields in a document and change them to a specific order number. Thanks for the help.

This topic has been closed for replies.

3 replies

jeremy0013
Inspiring
October 26, 2015

Thanks for all of your replies.  This is a pretty complex document as well I am very new to scripting illustrator.   I will have to do some more reading to figure out how to loop through everything and find all text frames. 

Silly-V
Legend
October 26, 2015

The simplest way is to do a loop like this:

for(var i=0; i<app.activeDocument.textFrames.length; i++){

  alert(app.activeDocument.textFrames.contents);

}

Silly-V
Legend
October 26, 2015

If it's always the same text fields and their contents change to show the same kind of information (e.g. the "order" textboxes are always used to contain order numbers), you can name or note, or tag or URL an identifier onto the desired text frames and use functions to loop through text frames in the entire document looking for this identifier. As well, you can simply put your special textframes into a single special layer (e.g. "Order Numbers") and have the script go through just that one layer, changing every single one of the text boxes.

CarlosCanto
Community Expert
Community Expert
October 24, 2015

since getByName always gets the first found element, you could save a reference to it, rename it and continue finding the next frames...rename back if necessary.

Disposition_Dev
Legend
October 26, 2015

I think carlos has the right answer. But i'll throw in my $.02 as well.

Depending on how complex the file is, you could also just loop a conditional statement that selects the textFrame if its name is "999999".