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

get the value of a text variable

New Here ,
Jan 27, 2017 Jan 27, 2017

//  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
2.4K
Translate
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

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';

Translate
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

Hello Ronald63,

Thank you very much! You made my day great!

Translate
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

This is what you are looking for:

InDesign ExtendScript API (12.0)

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

Translate
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
LATEST

Hello Vamitul,

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

Translate
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