Copy link to clipboard
Copied
Hi All,
I have one doubt. Please help me.
I am using the below code for find the text in document:
app.findTextPreferences=NothingEnum.NOTHING;
app.findTextPreferences.findWhat = "Sample text for finding";
var findCount = app.activeDocument.findText();
alert(findCount.length);
I don't know to find the all opened document. See below screenshot for more details:
Thanks,
Magesh
To put it all together:
app.findTextPreferences=NothingEnum.NOTHING;
app.findTextPreferences.findWhat = "Sample text for finding";
var findCount = app.documents.everyItem().findText();
var sum = 0;
for (var i = 0; i < findCount.length; i++) { sum += findCount[i].length; }
alert(sum);
Hi all, have you tried
app.findText()
- Mark
Copy link to clipboard
Copied
Through the magic of everyItem():
app.documents.everyItem().findText();
Copy link to clipboard
Copied
Thanks for your immediate reply!
I am update the code like below:
app.findTextPreferences=NothingEnum.NOTHING;
app.findTextPreferences.findWhat = "Sample text for finding";
var findCount = app.documents.everyItem().findText();
alert(findCount.length);
Now get only the document count. See below for more details:
Copy link to clipboard
Copied
Hi Magesh,
inspect what findCount really is.
It's an array of arrays.
The outer array contains one array for every open document.
You have two documents open, so inspect:
findCount[0].length
findCount[1].length
That should give you a better answer.
Regards,
Uwe Laubender
( Adobe Community Professional )
Copy link to clipboard
Copied
To put it all together:
app.findTextPreferences=NothingEnum.NOTHING;
app.findTextPreferences.findWhat = "Sample text for finding";
var findCount = app.documents.everyItem().findText();
var sum = 0;
for (var i = 0; i < findCount.length; i++) { sum += findCount[i].length; }
alert(sum);
Copy link to clipboard
Copied
Hi all, have you tried
app.findText()
- Mark
Copy link to clipboard
Copied
Thanks Mark
Your answer has met my need.