4 Replies Latest reply on Nov 12, 2012 5:24 AM by Siouxxx

    Changes only in text frames, not tables?

    Siouxxx

      I use a little script that loads saved searchqueries and execute them. The problem is: some corrections are only to do in textframes, not in tables. I don't know how to exclude tables so maybe someone here can help me? Here's the code:

       

      //start

      #target InDesign

       

      app.loadFindChangeQuery ('saved_query_text1', SearchModes.textSearch);

      app.activeDocument.changeText();

      app.loadFindChangeQuery ('saved_query_grep1', SearchModes.grepSearch);

      app.activeDocument.changeGrep();

      ...

       

      alert ("Finished");

      //end

        • 1. Re: Changes only in text frames, not tables?
          Jump_Over Level 5

          Hi,

          ...

          app.activeDocument.changeText();     // changeText() is proceeded in whole doc

          app.selection[0].changeText()     // changeText() area set to selection only;

          myTF.changeText()          // changeText() area set to text frame named "myTF";

           

          So your challange is to find a way to name your changeText() destination.

          It depends on your doc structure. If tables are in separated frames should be easy.

          But you have to say something about it.

           

          rgds

          • 2. Re: Changes only in text frames, not tables?
            Siouxxx Level 1

            Hi Jump_Over,

            Oh, I see. So every table in the document is in a separate frame.

            How can I select the textframes only? Must I use "switch" and then "parentTextFrames" or "parentStory"?

            And can I use "app.loadFindChangeQuery" for that?

            I think I have to build a loop instead of simply change all texts and define a var like "myTF", is that right?

             

            First many thanks for your helping

            Kindly regards

            Siouxxx

            • 3. Re: Changes only in text frames, not tables?
              Jump_Over Level 5

              Hi,

               

              So if we want to exclude textFrames with tables

              I suggest to proceed find/change procedure in 2 steps.

               

              1. myFound = myDoc.findText();

              You have an array with every findText() results.

               

              2. Hide changeText() into the loop statement:

              var k = myFound.length;

              while (k--)

                   if (myFound[k].parent.constructor.name !== "Cell")

                   myFound[k].changeText();

               

              This should change text only if its parent is not a table cell.

              hope...

              1 person found this helpful
              • 4. Re: Changes only in text frames, not tables?
                Siouxxx Level 1

                Thanks a lot, I will try asap.

                 

                Kindly regards

                Siouxxx