3 Replies Latest reply on Mar 20, 2016 4:23 PM by Trevorׅ

    Trying to get a collection of Textframes with the second table in my document

    VWu Level 1

      Dear all,

       

      There are two long tables in my document, and what I’m trying to do is to get the collections of text frames which contain the second table to resize them (only height),

      and set the column count to 3 columns and column gutter to 0, but I am unable to get the collections of text frames which contains the second table.

       

      I also want to apply a different master page to the pages contain the second table.

      I know I can change my column count and gutter by using below script, but the thing is I don't want the script to affect my first table,

      and I also cannot put the tables in separate file because there are cross references.

       

      //Script to change column count and gutter

      app.findObjectPreferences.textColumnCount = 1;

      app.changeObjectPreferences.textColumnCount = 3;

      app.documents.item(0).changeObject();

       

      app.findObjectPreferences.textColumnGutter != 0;

      app.changeObjectPreferences.textColumnGutter = 0;

      app.documents.item(0).changeObject();

       

      I am new to javascript and I have been searching for the solutions for several days but still can’t figure out how to get it work.

      Any input will be appreciated!

      V

        • 1. Re: Trying to get a collection of Textframes with the second table in my document
          Trevorׅ Adobe Community Professional

          Hi VWu,

           

          Depending on what you call the second table this might do what you want.

           

          var doc, secondTable, secondTableTextCotainer;
          doc = app.properties.activeDocument;
          if (!doc) {
              alert("Jerk");
              exit();
          };
          app.findTextPreferences = null;
          app.findTextPreferences.findWhat = "\x16";
          var tables = doc.findText(false);
          if (tables.length > 1) secondTable = tables[1];
          secondTableTextCotainer = secondTable.parentTextFrames[0];
          // You might want to change this line
          secondTableTextCotainer.fillColor = "Yellow";
          

           

          Trevor

          • 2. Re: Trying to get a collection of Textframes with the second table in my document
            VWu Level 1

            Hi Trevor,

             

            Thank you for your help. You are amazing!

            This script works well, but it will only get one parent text frame for me.

            I  am trying to get all parent text frames of my second table and also the pages these frames are on so I can apply master pages to them.

             

            Many thanks,

            VWu

            • 3. Re: Trying to get a collection of Textframes with the second table in my document
              Trevorׅ Adobe Community Professional

              I think this is what you want.

               

              var doc, secondTable, secondTableTextCotainers = [], ps, firstFrame, lastFrame, nextFrame;
              doc = app.properties.activeDocument;
              if (!doc) {
                  alert("Jerk");
                  exit();
              };
              app.findTextPreferences = null;
              app.findTextPreferences.findWhat = "\x16";
              var tables = doc.findText(false);
              if (tables.length > 1) secondTable = tables[1];
              else exit();
              lastFrame = secondTable.parent.insertionPoints[secondTable.index + 1].parentTextFrames[0];
              firstFrame = secondTable.parentTextFrames[0];
              secondTableTextCotainers.push(firstFrame);
              if (lastFrame != firstFrame) {
                  nextFrame = firstFrame;
                  while (nextFrame = nextFrame.nextTextFrame) {
                      secondTableTextCotainers.push(nextFrame);
                      if (nextFrame == lastFrame) break;
                  }
              }
              var l = secondTableTextCotainers.length;
              // You might want to change this line
              while (l--) secondTableTextCotainers[l].fillColor = "Yellow";