8 Replies Latest reply on Jul 19, 2013 5:31 AM by virender_CTS

    How to select two text boxes (linked) separated by a distance?

    virender_CTS Level 1

      dear all,

       

      how to select two boxes in an indd CS6 document? I tried to label them also but unable to select.

       

      Virender

        • 1. Re: How to select two text boxes (linked) separated by a distance?
          Jump_Over Level 5

          Hi,

           

          Assumed there are page items named "box1" and "box 2" anywhere inside mDoc:

          mDoc = app.activeDocument;
          mDoc.pageItems.item("box1").select();
          mDoc.pageItems.item("box2").select(SelectionOptions.ADD_TO);
          

           

          other select options:

               SelectionOptions.REMOVE_FROM

               SelectionOptions.REPLACE_WITH

           

          use

          Adobe InDesign CS5 (7.0) Object Model

          or another placed here: http://jongware.mit.edu

           

          rgds

          Jarek

          • 2. Re: How to select two text boxes (linked) separated by a distance?
            Laubender Adobe Community Professional & MVP

            @Jarek – "anywhere"? No.
            They have to be on the same spread, if you want to select them…

             

            @Virender – if you want to address the two text frames without selecting them, this limitation does not apply.

             

            Addressing objects by name is tricky. You have to make sure, that there are no objects with the same name. Otherwise you could end up with the wrong object…

             

            A unique identifier could be the ID number of a text frame…

             

            Uwe

            • 4. Re: How to select two text boxes (linked) separated by a distance?
              virender_CTS Level 1

              Dear Jarek, Dear Uwe,

               

              thanks much but I am using CS6 (Adobe Indesign CS6(8.0) model), above coding is not working. Please advise alternative method for selecting both text boxes. They are on same page.

               

              Virender

              • 5. Re: How to select two text boxes (linked) separated by a distance?
                Jump_Over Level 5

                Hi,

                 

                Jumping to the next alternative method is a never ending story. First try to figure out why the basic method doesn't work.

                - What error is shown?

                - Is this 3-liner code a part of the bigger one?

                - Are the assumings done properly?

                 

                Jarek

                • 6. Re: How to select two text boxes (linked) separated by a distance?
                  virender_CTS Level 1

                  Hi,

                   

                  agreed . Lets resolve the existing coding.

                   

                  #target indesign

                  var myDoc = app.activeDocument;
                  myDoc.pageItems.item("box1").select();    //error appear here (Object is invalid)
                  myDoc.pageItems.item("box2").select(SelectionOptions.ADD_TO);  // even if delete this line.

                  - Object is invalid.

                  - no i just used above code in a separate new script. only above these lines are present.

                  - Yes, you can see coding above.

                   

                  virender

                  • 7. Re: How to select two text boxes (linked) separated by a distance?
                    Laubender Adobe Community Professional & MVP

                    @Virender – as I remember, something changed from Indesign CS4 to CS5 (and still applies to the recent versions of InDesign).

                     

                    There are three different methods to apply something as a "Name" to a text frame:

                     

                    1. The "Label" method in the UI with the Scripting Label Panel
                    You can retrieve that label with the label property like that:

                     

                    //The text frame is selected:

                     

                    var myLabel = app.selection[0].label;

                     

                    But since there is no pageItems.itemByLabel("myLabelString") method, this is useless here…

                    To retrieve a label you have to iterate through all text frames on the page to sort out the right text frame…

                     

                    2. Or you inject a script label with the insertLabel("keyString","valueString") method and retrieve the inserted label with extractLabel("keyString") method. That means that you have to iterate through all text frames on the page to sort out the right one…

                     

                    3. The "Name" method in the UI: you can rename every page item shown in the Layers Panel.
                    You can retrieve that name with the name property like that:

                     

                    myDoc.pageItems.itemByName("myNameString").select();

                     

                    or:

                     

                    myDoc.pageItems.item("myNameString").select();

                     

                     

                     

                    For the whole discussion (and some solutions) about this see:

                     

                    With CS5, some things have changed

                     

                    http://forums.adobe.com/message/2728529#2728529

                     

                    Uwe

                    • 8. Re: How to select two text boxes (linked) separated by a distance?
                      virender_CTS Level 1

                      Dear Uwe, Many thanks for your points.

                      I have 10 indd files and each file has one page and a table is only item present on page. So few files has table present in one table and few files has two text boxes because table has many rows so spiltted in two linked text boxes.

                      I somehow able to select both text boxes but while exporting them only one text box table get exported as png because of improper code.

                       

                       

                      #target Indesign

                      var sourceFolder = new Folder ("/Users/admin4/Desktop/INS");

                      var myFiles = sourceFolder.getFiles();

                       

                      //alert (myFiles.length);

                      var destFolder = new Folder ("/Users/admin4/Desktop/folder3");

                       

                      for (i=0; i < myFiles.length; i++)

                      {

                           if (myFiles[i].name !=".DS_Store")

                           {

                           var sourceDoc = app.open(myFiles[i]);

                          

                           app.activeDocument.pageItems.everyItem().select();

                       

                           //app.activeDocument.stories[0].tables[0].parent.select();

                       

                           var destFile = File(destFolder + "/" + myFiles[i].name + ".png");

                       

                           app.selection[0].exportFile(ExportFormat.PNG_FORMAT, destFile, false);  

                           // here i need to correct code.

                       

                           sourceDoc.close(SaveOptions.NO);

                       

                          }

                      }