Copy link to clipboard
Copied
I have see there is a script for counting how many words in a document.
Also,Is there a script can count How many lines,and one line have how many words In a text box?
And they should be combined in a script.
Thank you~~
Copy link to clipboard
Copied
Hi ednly,
Is this is your requirement:
var myWords = app.activeDocument.stories.everyItem().words.everyItem().getElements();
alert("words in the document: " + myWords.length)
var myLines = app.activeDocument.stories.everyItem().lines.everyItem().getElements();
alert("lines in the document : " + myLines.length)
myCount = 0;
for(i=0; i<myLines.length; i++)
{
myCount++
var myWords = myLines.words.everyItem().getElements();
alert("Line " + myCount + ": " + myWords.length + " words count")
}
Regards
Siraj
Copy link to clipboard
Copied
Copy link to clipboard
Copied
hi ednly,
the script by Siraj works perfectly. If you need to know the counts for one text box e.g. selected box then here is the script.
var myWords = app.activeDocument.stories.everyItem().words.everyItem().getElements();
$.writeln("total words in the document: " + myWords.length) // you can replace $.writeln with alert if you want.
var myDoc = app.activeDocument;
var mytextFrame = myDoc.selection[0];
if (myDoc.selection.length == 1)
{
var myLines = mytextFrame.lines //.everyItem().getElements;
$.writeln("lines in the selected text frame are : " + myLines.length)
myCount = 0;
for(i=0; i<myLines.length; i++)
{
myCount++
var myWords = myLines.words.everyItem().getElements();
$.writeln ("Line " + myCount + ": " + myWords.length + " words count")
}
}
else {
alert ("No text frame is selected");
}
virender
Copy link to clipboard
Copied
Hi virender~
No any response
Copy link to clipboard
Copied
hi edny,
the count will appear at Window => "Javascript console", once you run script.
Otherwise $.writeln with alert in script to see as alert.
virender
Copy link to clipboard
Copied
Oh my god ~~
I would to do it in Indesign Cs6