3 Replies Latest reply on Jan 26, 2009 1:36 PM by Loic.Aigon

    selecting text frames on multiple pages

    Level 1
      hello all -

      i have a problem i believe is tailor-made for a script, but i don't know enough about scripting to tackle it. in CS3, i have a 300+ page document and i wish to select all text frames and change their Y position. is there a script that exists for this? the "select objects" script in indesign sadly doesn't select across multiple pages.

      thanks!
      micah
        • 1. Re: selecting text frames on multiple pages
          Level 1
          A script cannot do things that are impossible in the UI. So, selecting on more than one page is not possible.

          However, to do what you want, a script doesn't have to select anything.
          //DESCRIPTION: move all text frames in document 12 units down
          

          ( function() {
            if (app.documents.length > 0) {
              moveTextFrames(app.documents[0], [0,12]);
            }
            function moveTextFrames(doc, offset) {
              var spreads = doc.spreads.everyItem().getElements();
              for (var j = spreads.length - 1; j >= 0; j--) {
                spreads[j].textFrames.everyItem().move(undefined, offset);
              }
            }
          }())
          To move by some other amount, change the values (that's x and y in the units you're using) in the moveTextFrames call.

          Interestingly, for this to work, you have to go a spread at a time. I expected that:

          >app.documents[0].textFrames.everyItem().move(undefined, [0,12]);

          would work, but it didn't. Gave me the dreaded: this will cause an item to be moved off the pasteboard message.

          Dave
          • 2. Re: selecting text frames on multiple pages
            Loic.Aigon Adobe Community Professional
            you cannot select all textframes at once as you can't do in the UI.<br />however you can create a collection of textframes and loop thought it to move the positions.<br />var mytf = app.activeDocument.textFrames.everyItem().getElements();<br />for(i=0; i<mytf.length; i++)<br />{<br />     var x = mytf[i].geometricBounds[1];<br />     var y = 2 //for example;<br />     mytf[i].move([x,y]);<br />}<br />I tried [undefined,2] but it seems you cannot avoid move only one axis only.<br /><br />Loic
            • 3. Re: selecting text frames on multiple pages
              Loic.Aigon Adobe Community Professional
              Oh Dave has already been by here and already corrected me :-)
              b spreads[j].textFrames.everyItem().move(undefined, offset);
              i I tried [undefined,2] but it seems you cannot avoid move only one axis only.