Skip to main content
erwine7220
Participating Frequently
January 27, 2017
Question

get the value of a text variable

  • January 27, 2017
  • 2 replies
  • 2465 views

//  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?

This topic has been closed for replies.

2 replies

Vamitul
Legend
January 28, 2017

This is what you are looking for:

InDesign ExtendScript API (12.0)

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

erwine7220
Participating Frequently
January 30, 2017

Hello Vamitul,

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

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

erwine7220
Participating Frequently
January 30, 2017

Hello Ronald63,

Thank you very much! You made my day great!