• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

get the value of a text variable

New Here ,
Jan 27, 2017 Jan 27, 2017

Copy link to clipboard

Copied

//  In my active Indesign document, there is a Text variable named myRevisionNR, type: modified text, which can be: "00", or "01" or "02", etc.

//  How can I display the "value" of my tex variable myRevisionNR?

//

//  Create text variable

var myDocVariables = app.activeDocument.textVariables;

var myDocVariablesNames = myDocVariables.everyItem(0).name;

//  The following sentence only displays: "myRevisionNR". But I want to see: "01", or "02"

alert(myDocVariablesNames[0])

//  Who can help me?

TOPICS
Scripting

Views

2.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 27, 2017 Jan 27, 2017

Copy link to clipboard

Copied

Hello,

Try this ...

// get text variable value

var myValue= app.activeDocument.textVariables.item('myRevisionNR').variableOptions.contents;

alert(myValue)

// set text variable value

app.activeDocument.textVariables.item('myRevisionNR').variableOptions.contents = '03';

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 30, 2017 Jan 30, 2017

Copy link to clipboard

Copied

Hello Ronald63,

Thank you very much! You made my day great!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jan 27, 2017 Jan 27, 2017

Copy link to clipboard

Copied

This is what you are looking for:

InDesign ExtendScript API (12.0)

(app.activeDocument.textVariables[0].associatedInstances[0].resultText)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 30, 2017 Jan 30, 2017

Copy link to clipboard

Copied

LATEST

Hello Vamitul,

Thank you for answerign my question. I will take a look at it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines