Copy link to clipboard
Copied
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 hav
...Copy link to clipboard
Copied
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 ...
Copy link to clipboard
Copied
And I'm pretty sure should be texts[] ?
texts |
readonly |
A collection of text objects. |
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Story.html
Copy link to clipboard
Copied
Hi @Robert at ID-Tasker thank you.
This worked
Copy link to clipboard
Copied
Hi @virender_CTS , Also, you might want to get all of the texts, and if you want to be sure about the language use itemByName (I get Hindu when I use item 3)
var lang = app.languagesWithVendors.itemByName("German: Swiss");
var s = app.activeDocument.stories.everyItem().texts.everyItem().appliedLanguage = lang;
Copy link to clipboard
Copied
[...] you might want to get all of the texts, [...]
By @rob day
Out of curiosity - how can there be more than one Text in Texts collection??
Copy link to clipboard
Copied
Can’t think of a way, but the object model implies there is.
Copy link to clipboard
Copied
Then maybe done this way "just in case"?
It wouldn't be such a bad thing if it would automatically list / return references to texts from all anchored "objects" - TextFrames or Foot- / End-Notes - or even Hyperlinks / Bookmarks / Cross-Refs - in the order of appearance - as all those things are available in their own collections anyway...
Copy link to clipboard
Copied
Noted, will check with my colleagues and change to itemByName.
Copy link to clipboard
Copied
Actually, I don’t think you need texts—a story has an applied language property:
This would get all stories as well as table cells:
var lang = app.languagesWithVendors.itemByName("German: Swiss");
app.activeDocument.stories.everyItem().appliedLanguage = lang;
//get table texts if they exist
try {
app.activeDocument.stories.everyItem().tables.everyItem().cells.everyItem().texts.everyItem().appliedLanguage = lang;
}catch(e) {}
Copy link to clipboard
Copied
But it can't ?? And just checked - you need to use texts[0].
Or as per @rob day example - just texts without [].