Highlighted

Document textframe count

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

Try

alert(app.activeDocument.textFrames.length);

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

TOPICS
Bug, Scripting

Views

85

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

Document textframe count

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

Try

alert(app.activeDocument.textFrames.length);

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

TOPICS
Bug, Scripting

Views

86

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
Jul 24, 2020 0
Adobe Community Professional ,
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
Reply
Loading...
Jul 24, 2020 0
Enthusiast ,
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
Reply
Loading...
Jul 25, 2020 0