Reply To: How to capitalize first letter in a text box

Home Page / Forums / General InDesign Topics (CLOSED) / How to capitalize first letter in a text box / Reply To: How to capitalize first letter in a text box

#101892

David,

After test, I really think it could be done as I said above [but we’ll need 2 clicks! …] because we talk about 2 docs:
English version vs. English version + text frames added for the dutch translation!

So, imho, it’s simple:

1/ Open the “English version” and play this:

//————————————————————————————————————-

var myTextFrames = app.activeDocument.textFrames.everyItem().getElements(),
T = myTextFrames.length, t,
myIDs = [];
for ( var t = 0; t < T; t++ ) myIDs.push(myTextFrames[t].id);
myIDs.sort(sortnum);
function sortnum (a, b) {return a > b};

alert (myIDs[T-1]);

//————————————————————————————————————-

This script will give us the bigger ID of text frame included into the English version InDesign file ==> XXXX. [close this file without saving it]

2/ Then open the Dutch version and play this 2nd script modifying “XXXX” by the number given by the first script :

//————————————————————————————————————-

var myTextFrames = app.activeDocument.textFrames.everyItem().getElements(),
T = myTextFrames.length, t;
for ( var t = 0; t < T; t++ ) if ( myTextFrames[t].id > XXXX ) myTextFrames[t].characters[0].changecase (ChangecaseMode.uppercase);

//————————————————————————————————————-

Done! =D

The 2nd script will only change the case of the first char of a text frame IF the ID of this text frame is bigger than XXXX!
… More clearly, if that frame has been created later than the most recent text frame of the English version!

Simply cool! …

Good night!

Michel, from FRIdNGE

This article was last modified on February 20, 2018

Comments (0)

Loading comments...