13 Replies Latest reply on Jul 22, 2010 7:36 PM by PankChat

    Inserting text frame and threading it to previous/nextTextFrame

    PankChat Level 1

      Hello all,

       

      I am trying to add a textframe frame if it is missing on a given page labelling it with "main". Next, threading it to the previous or next textframe with same label "main". All is well, though the added textframe is not being threaded with any (prev/next) textframe. Below is the snippet what I have written till now.

       

      ------

      ------
      for (var i=0; i<=myTotalPage-1; i++)
      {
      //Create a frame if "main" is missing on page
                
      if(!(myDoc.pages[i].textFrames.itemByName("main")!=null))
          {
              var myPage=myDoc.pages[i];
              var myPreviousPage = myDoc.pages.previousItem(myPage);
              var myNextPage = myDoc.pages.nextItem(myPage);
              var myTextFrame = myPage.textFrames.add();
              myTextFrame.geometricBounds = myGetBounds(myDoc, myPage);
              myTextFrame.label="main";

       

      //Do not Thread the new added text frame on page to previous as well as next
      try{
                      previousTextFrame=myDoc.pages[i].textFrames.itemByName("main");
                          nextTextFrame=myDoc.pages[i].textFrames.itemByName("main");
      }catch(e){}
          }
      }

       

      What could be the possibily incorrect in code or its a totally wrong approach?

      Any Ideas in this regard will be highly appreciated.

       

      Best,

      --PC