How to search All Documents

Explorer ,
Jun 28, 2022 Jun 28, 2022

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:

Mageshwaran_0-1656434924016.png

 

 

Thanks,
Magesh

 

TOPICS
Scripting

Views

73

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Adobe Community Professional , Jun 28, 2022 Jun 28, 2022

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);

Likes

Translate

Translate
Adobe Community Professional , Jun 28, 2022 Jun 28, 2022

Hi all, have you tried

app.findText()

- Mark

Likes

Translate

Translate
Adobe Community Professional ,
Jun 28, 2022 Jun 28, 2022

Copy link to clipboard

Copied

Through the magic of everyItem():

app.documents.everyItem().findText();

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 28, 2022 Jun 28, 2022

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:

Mageshwaran_0-1656436117246.png

 

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 28, 2022 Jun 28, 2022

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 )

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 28, 2022 Jun 28, 2022

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);

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jun 28, 2022 Jun 28, 2022

Copy link to clipboard

Copied

Hi all, have you tried

app.findText()

- Mark

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 28, 2022 Jun 28, 2022

Copy link to clipboard

Copied

LATEST

Thanks Mark

Your answer has met my need.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines