Skip to main content
Inspiring
October 5, 2023
Answered

Change applied language in anchored boxes

  • October 5, 2023
  • 1 reply
  • 961 views
Hi All,
This is a part of the script where I have been trying to change the applied language in a document to all textFrames to Swiss German. It is working fine but no changes in anchored textFrames.
Any suggestion please.
 
var myDoc = app.activeDocument;
myDoc.textFrames.everyItem().text[0].appliedLanguage = app.languagesWithVendors[3];
 
Regards
Virender
 
This topic has been closed for replies.
Correct answer Robert at ID-Tasker

Anchored TextFrames are not directly listed in the Document - you would have to add one more level of everyItem():

 

myDoc.textFrames.everyItem().texts[0].textFrames.everyItem().texts[0].appliedLanguage = app.languagesWithVendors[3];

 

or something like that - I'm not JS guy so if it won't work - you'll have to wait for JS Gurus.

 

But why are you processing TextFrames - and not Stories?

 

Should work much faster - every TextFrame ALWAYS have parentStory - can't exists WITHOUT - and if Story have multiple TextContainers = TextFrames - do not confuse with Anchored / InLine TextFrames and other objects  - then you'll refer to the contents of all of those containers only once.

 

BUT - why can't you just modify ParaStyles? If you have them correctly applied of course ...

 

1 reply

Robert at ID-Tasker
Robert at ID-TaskerCorrect answer
Legend
October 5, 2023

Anchored TextFrames are not directly listed in the Document - you would have to add one more level of everyItem():

 

myDoc.textFrames.everyItem().texts[0].textFrames.everyItem().texts[0].appliedLanguage = app.languagesWithVendors[3];

 

or something like that - I'm not JS guy so if it won't work - you'll have to wait for JS Gurus.

 

But why are you processing TextFrames - and not Stories?

 

Should work much faster - every TextFrame ALWAYS have parentStory - can't exists WITHOUT - and if Story have multiple TextContainers = TextFrames - do not confuse with Anchored / InLine TextFrames and other objects  - then you'll refer to the contents of all of those containers only once.

 

BUT - why can't you just modify ParaStyles? If you have them correctly applied of course ...

 

Robert at ID-Tasker
Legend
October 5, 2023

And I'm pretty sure should be texts[] ?

 

texts

Texts Text

readonly

A collection of text objects.

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Story.html

 

Inspiring
October 5, 2023

Hi @Robert at ID-Tasker thank you.

This worked

myDoc.stories.everyItem().text[0].appliedLanguage = app.languagesWithVendors[3];