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

Document textframe count

Participant ,
Jul 24, 2020 Jul 24, 2020

Copy link to clipboard

Copied

Hi professionals,

I have used this code to find the textframe count but it shows an script error. Please guide me

 

var myDoc = app.activeDocument;
var myText= 0;
for (var i = 0; myDoc.stories.length > i; i++)
myText += myDoc.textFrames[i].texts.length
alert("Document contains " + myText + " textframe.");

eerror.png

-Monisha
TOPICS
Bug , Scripting

Views

600

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 1 Correct answer

Enthusiast , Jul 25, 2020 Jul 25, 2020

Try

alert(app.activeDocument.textFrames.length);

This will count all text frames, including the ones placed in any master page. 

Votes

Translate

Translate
Community Expert ,
Jul 24, 2020 Jul 24, 2020

Copy link to clipboard

Copied

This code to me seems to be incoherent. Why do you iterate stories and then check the text length and conclude that it would be the frame count. Try to find answers to the following question

  • Is there a one to one relation between stories and textframes?
  • How is a textframe related to the text object
  • Isn't the a more simpler way to get the textframe count, some inbuilt collections that you could use. Search the DOM documentation

--Manan

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
Enthusiast ,
Jul 25, 2020 Jul 25, 2020

Copy link to clipboard

Copied

Try

alert(app.activeDocument.textFrames.length);

This will count all text frames, including the ones placed in any master page. 

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
New Here ,
Oct 25, 2021 Oct 25, 2021

Copy link to clipboard

Copied

You tell correct. but it come anchore or inline text frame then it not countable.

Thanks,

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 ,
Oct 25, 2021 Oct 25, 2021

Copy link to clipboard

Copied

LATEST

Hi Thiru5CD0,

if you want to count or access all text frames in the document you have to loop all textContainers arrays of all stories in the document and filter out the text paths that are also text containers.

 

Regards,
Uwe Laubender

( ACP )

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