Skip to main content
Inspiring
May 30, 2016
Answered

How to define text frames loop through the active doc

  • May 30, 2016
  • 2 replies
  • 315 views

Hi experts

I have this script:

var myDoc = app.activeDocument;

    myTextFrame = myDoc.textFrames;

    for (var F = myTextFrame.length; F > 0; F --){

while (myTextFrame.overflows)

    myTextFrame.parentStory.pointSize -= 0.5;

    }

but I always get error after run the script, could someone tells me what's wrong with the define?

regard

John

This topic has been closed for replies.
Correct answer tpk1982

not sure, but this will work

var myDoc = app.documents[0];

var myPages = myDoc.pages;

for (var i = 0; i < myPages.length; i++) {

    var myPage = myDoc.pages.item(i) ;

    var myFrame= myPage.textFrames;

    for (var m = 0; m < myFrame.length; m++) {

        if ( myFrame.item(m).overflows ) {

                myFrame.item(m).parentStory.pointSize -= 0.5;

        }  

    };

};

2 replies

JohnwhiteAuthor
Inspiring
May 30, 2016

thank you ptk1982, thank all guys,

so it is not allow to directly define the text fame,

so the hierarchy so be like: doc -> pagesItems -> text frame

thanks so much.

regard

John

tpk1982
tpk1982Correct answer
Legend
May 30, 2016

not sure, but this will work

var myDoc = app.documents[0];

var myPages = myDoc.pages;

for (var i = 0; i < myPages.length; i++) {

    var myPage = myDoc.pages.item(i) ;

    var myFrame= myPage.textFrames;

    for (var m = 0; m < myFrame.length; m++) {

        if ( myFrame.item(m).overflows ) {

                myFrame.item(m).parentStory.pointSize -= 0.5;

        }  

    };

};