Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Document textframe count

Explorer ,
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

245

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

Enthusiast , Jul 25, 2020 Jul 25, 2020
Tryalert(app.activeDocument.textFrames.length);This will count all text frames, including the ones placed in any master page. 

Likes

Translate

Translate
Adobe Community Professional ,
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

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
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. 

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
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,

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

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