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

Adding Text variables (javascript)

Explorer ,
Dec 10, 2024 Dec 10, 2024

Copy link to clipboard

Copied

Is it possible to add a text variable and set all options via js?

var myV = app.activeDocument.textVariables.add({name: 'TCD', variableType: VariableTypes.MATCH_CHARACTER_STYLE_TYPE});
myV.preferences.searchStrategies = SearchStrategies.LAST_ON_PAGE;
myV.searchStrategies = SearchStrategies.LAST_ON_PAGE;

 

The second and the third line don't work. Is it possible to set the options like search strategies, characterStyle, text after & before etc. via script?

MatchCharacterStyleType is read only.

TOPICS
Scripting

Views

72

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
Community Expert ,
Dec 10, 2024 Dec 10, 2024

Copy link to clipboard

Copied

LATEST

Hi @mateuszp13156491, you need to set the variableOptions of the textVariable, which in this case will be a MatchCharacterStylePreference object. So use this in your code:

myV.variableOptions.searchStrategy = SearchStrategies.LAST_ON_PAGE;

- Mark 

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