8 Replies Latest reply on Feb 9, 2011 9:19 AM by thomas.jeorge

    Target empty textframe


      Hi Groups,


      I want to find an empty text frame in my documents. Some empty text frame are grouped with other text box.


      What is the js code to find empty text frame with grouped items.




        • 1. Re: Target empty textframe
          Mi_D Level 3

          dear Thomas,

          try below code


          var myDocument = app.activeDocument;

          var myPage = myDocument.pages;

          for (var p=0; myPage.length>p; p++){

          var myTextFrame = myDocument.allPageItems;

          for(var i = (myDocument.allPageItems.length-1); i>0; i--)


          var sel=  app.select (myTextFrame[i]);


          var myselect =app.selection[0]


          if(myTextFrame[i].contents == 0)














          • 2. Re: Target empty textframe
            thomas.jeorge Level 1

            Dear Mi_D


            Thanks for your answer. It removes the empty text frame and select another textframes.


            Can we only select the empty textframe from this script? Please suggest how?




            • 3. Re: Target empty textframe
              Mi_D Level 3

              Dear Thomas

              For find the empty frame first select every item and check first text frame it is a text frame than check content is there or not if conten is null than remove the frame


              if u went at end it not select and frame thean add line before last curle bracket

              app.select(NothingEnum.nothing, undefined);



              • 4. Re: Target empty textframe
                thomas.jeorge Level 1

                Dear MiD,


                Thanks for  your reply. I couldn't get my target.


                I need to show and select my empty textframe one by one. This code removes all the empty text frame.


                Any help on this regard.



                • 5. Re: Target empty textframe
                  thomas.jeorge Level 1

                  Is there any one who can help me to select and alert my empty

                  text frame one by one in my document? Please help.



                  • 6. Re: Target empty textframe
                    [Jongware]-9BC6tI Level 4

                    You are forgetting a script can only run once, and then it can find (= select) a single textframe. Scripts don't (in general) wait for you to do your thing, then "find next". It would need a construction with some modeless palette, or something.


                    As it is, each time you run a script, it will at best find the first empty text frame -- even though you think, no, I already saw it and wish to ignore that one, go find the next. A script needs to be able to identify which ones you'd want to ignore.

                    • 7. Re: Target empty textframe
                      herr mueller Level 1

                      You can however:


                      1. Itterate through the textframes collection, selecting each item in turn
                      2. then utilize a confirm to ask if you want to delete the selected object or not
                      3. If true, store a reference to the object in an array
                      4. Finally delete the referenced objects after the for loop completes.
                      • 8. Re: Target empty textframe
                        thomas.jeorge Level 1

                        Thanks a lot for your response.


                        I am new comer in this forum. And I am still learning js. Thats why I am asking this silly question.


                        Anyways, How can we alert first empty text frame? Help me.