• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

285

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

Community Expert , 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);

Votes

Translate

Translate
Community Expert , Jun 28, 2022 Jun 28, 2022

Hi all, have you tried

app.findText()

- Mark

Votes

Translate

Translate
Community Expert ,
Jun 28, 2022 Jun 28, 2022

Copy link to clipboard

Copied

Through the magic of everyItem():

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

Votes

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

 

 

 

Votes

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
Community Expert ,
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 )

Votes

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
Community Expert ,
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);

Votes

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
Community Expert ,
Jun 28, 2022 Jun 28, 2022

Copy link to clipboard

Copied

Hi all, have you tried

app.findText()

- Mark

Votes

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.

Votes

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