Script to convert all text variables

Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Script to convert all text variables

Viewing 11 reply threads
  • Author
    Posts
    • #59907
      jpannier
      Member

      Is there a script to convert all text variables in all open documents at once?

      Jeldrik

    • #59934
      tomaxxi
      Member

      Hey Jeldrik,

      Try this:

      try{
      for(var i = 0; i < app.documents.length; i++){
      app.activeDocument.stories.everyItem().textVariableInstances.everyItem().convertToText();}
      }catch(e){alert("Something gone wrong!r" + e);};

      Hope that helps.

      Marijan (tomaxxi)

    • #59936

      Hi Marijan!

      The script is good also for converting Live Captions into text since they are basically a Variable Text.

      JC

    • #59937
      tomaxxi
      Member

      jctremblay said:

      Hi Marijan!

      The script is good also for converting Live Captions into text since they are basically a Variable Text.

      JC


      Exactly! :-)

    • #59940
      jpannier
      Member

      Thanks Marijan,

      I'll test it tomorrow. I'm glad you helped me. It's an important piece in things of creating page numbers within epubs (by using a text variable pointing to an automatic generated page number by a paragraph stile and anchor it after the last character of a textframe before splitting the story and replacing all the special characters – see my post: https://creativepro.com/for&#8230;..n-an-epub).

      Greetings from Germany

      Jeldrik

    • #59942
      jpannier
      Member

      It works perfect – thanks again.

      Jeldrik

    • #60025

      I'm trying to do something similar in Applescript, for much the same reason. But

      tell (every text variable instance) to convert to text

      doesn't seem to work. I get the following:

      error “Adobe InDesign CS5 got an error: every text variable instance of active document doesn’t understand the convert to text message.” number -1708 from every text variable instance of active document

      Yet the dictionary seems to indicate that this ought to work:

      convert to text specifier : Supported by the following objects: note, footnote, text variable, text variable instance.

      Any ideas?

    • #60029

      Ah, I'm being stupid again.

      tell (every text variable instance of every story) to convert to text

      That does it.

    • #75944

      Can you help me? I am using text variables to create my running footers in a book. I created a variable that pulls from my aheads within each chapter to create my running footers. I now want to change part of the running footer. When I convert all text variables my running footer variable convert to the variable name I created, they are no longer repeating the aheads. Am I dreaming that this script can do this, or am I doing something wrong. Hope you can understand what I am trying to describe. Thanks so much. Liseann

    • #97170

      Hi there,

      Trying to revive this discussion as I have the exact same problem as Liseann above. My footer text variables get converted to the variable name since they are on master pages. To get around this, I would like to make this script only apply to text variables on unlocked layers. That way I can lock my pagination layers and leave them as variables. Any ideas?

    • #98152

      No need! simply exclude the master pages!

      I’ve a script for that! … But, not for free!

      (^/)

      [email: [email protected]]

      • #101207

        For the record—Obi’s script works like a charm!

        I just purchased and even had him customize it (to perform on multiple documents within a folder)—it works beautifully!!!


        Ashley
        https://www.girlfromthemoon.com

    • #14335625

      Hi guys.
      I’m new to InDesign scripts.

      I tried to copy and paste the code and it does not work. I paste it in a plain text document changing the extension to .jsx Tried tweaking and deleting the word “try” at the beginning, the semicolon at the end and other digits but nothing works. I get an error message.

      This is the code I have been using (the same that tomaxxi wrote)

      try{
      for(var i = 0; i < app.documents.length; i++){
      app.activeDocument.stories.everyItem().textVariableInstances.everyItem().convertToText();}
      }catch(e){alert(“Something gone wrong!r” + e);};

      What am I doing wrong? Can someone link a script document so I can downloaded it please. :)

      • #14335679
        David Blatner
        Keymaster

        What is the error?
        One of the most common problems when copying and pasting scripts is that curly quotes often have to be changed to straight quotes. Are the quote marks straight in your code?

Viewing 11 reply threads
  • You must be logged in to reply to this topic.
>