Skip to main content
Participating Frequently
July 5, 2011
Question

Script to Make all text Dynamic

  • July 5, 2011
  • 2 replies
  • 22864 views

Is there a way or a script that will make all the text on a page Dynamic? At the moment we have to select each text box and press 'make text dynamic', which can get tiresome with a lot of text boxes. If we select all the text boxes and do the same we get a lot of variables with the same name which gives an error.

So we need a script that can make it all dynamic with different named variables.

Anyone....

This topic has been closed for replies.

2 replies

bsf2017
Inspiring
April 12, 2017

How can I test the length of the itext variable, i.e. how long the text in my text box is?

itext.contentVariable.length produces "unknown".

Thanks

Silly-V
Legend
April 13, 2017

You can only do this when the variable's text is populated into the text frame. It then could be retrieved like this: app.activeDocument.textFrames[0].contents

CarlosCanto
Community Expert
Community Expert
July 6, 2011

here you go, it doesn't deal with errors. Delete all existing variables before running.

#target illustrator

// script.name = makeAllTextDynamic.jsx;

// script.description = makes ALL text Dynamic, creates Variables;

// script.required = one document with at leas one textFrame;

// script.parent = CarlosCanto // 7/5/11;

// script.elegant = false;

var idoc = app.activeDocument;

for (i=0; i<idoc.textFrames.length; i++)

     {

          var itext = idoc.textFrames;

          var idocvar = idoc.variables.add();

          idocvar.kind = VariableKind.TEXTUAL;

          itext.contentVariable = idocvar;

     }

Participating Frequently
February 16, 2013

Wow thanks for this! I just starting using this for some translation work I'm doing.

One question - how could I get it to only look at what is on the artboard and ignore text boxes that are on the pasteboard?

Thanks in advance! Very appreciated.

CarlosCanto
Community Expert
Community Expert
February 16, 2013

here you go, I thought it would be better if it works with selected objects, instead of what's in the artboard...so, select your text before running. You can marquee around your art and select other objects if they are in your way, they will all be ignored, only text will be turned into variables

#target illustrator

// script.name = makeSelectedTextDynamic.jsx;

// script.description = makes SELECTED text Dynamic, creates Variables;

// script.required = one document with at leas one textFrame;

// script.parent = CarlosCanto // 2/15/13

// script.elegant = false;

var idoc = app.activeDocument;

var sel = idoc.selection;

for (i=0; i<sel.length; i++) {

      var itext = sel;

      if (itext.typename=="TextFrame") {

          var idocvar = idoc.variables.add();

          idocvar.kind = VariableKind.TEXTUAL;

          itext.contentVariable = idocvar;

      }

}