13 Replies Latest reply on Jul 24, 2015 6:17 AM by Xand94

    Textframe merge or grouping


      Hi All,


      First real stab at indesign scripting to set up some packaging artwork.


      for component information on the box I am creating a textframe with all the various bits of info in there, ingredients etc. ince i have done this i create another 2 textframes each with an image in that tags onto the end of the weight line.


      Now that i have these 3 textboxes on the page (i had multiple versions of these three) my script continues to work out where best to place this one the artwork based on available space and moves it with .geometricBounds. My problem is that I can't find a good way to group these 3 textframes and then relocate them to the new position.


      is there a way of grouping or merging these 3 frames so that I can perform one command to move all 3?

        • 1. Re: Textframe merge or grouping
          Vamitul Level 4

          var myGroup=myDocument.groups.add([textFrame1,textFrame2,textFrame3]);


          • 2. Re: Textframe merge or grouping
            Xand94 Level 1

            Thanks for the response,


            I have given that a try but receive the following error "Invalid value for parameter 'groupitems' of method 'add'. Expected Array of PageItems but received nothing.


            please see my code below


            cFrame = myDocument.textFrames.item("compFrame["+index+"]");

            cFrameE = myDocument.textFrames.item("imageFrameE["+index+"]");

            cFrameSL = myDocument.textFrames.item("imageFrameSL["+index+"]");

            var myGroup = myDocument.groups.add([cFrame,cFrameE,cFrameSL]);

            myGroup.move([aX, newY]);


            unsure if the following info is relevant but I have already written the frames to the screen, auto sized them and due to them not being in the global scope and this function being in an included file I have to find and redeclare them with the first 3 lines.


            if you have any ideas on how to fix the above it would be greatly appreciated.

            • 3. Re: Textframe merge or grouping
              Ronald63 Level 4

              How do you determine this "compFrame["+index+"]" ?

              • 4. Re: Textframe merge or grouping
                Xand94 Level 1

                running through the following loop


                for (index = 0; index < frames.length; ++index) {




                the textframes were named to meet the compFrame["+index"+ schema during creation.

                • 5. Re: Textframe merge or grouping
                  Vamitul Level 4

                  try doing:
                  cFrame = myDocument.textFrames.item("compFrame["+index+"]").getElements()[0];


                  if not, please post the indd document so we can test.

                  • 6. Re: Textframe merge or grouping
                    Xand94 Level 1

                    doing the above works for the cFrame


                    unfortunately it seems to error on the second two imageFrames which are both just textframes with a single image loaded into them. the error is "Object is invalid"


                    the document in question is entirely generated from a database so can't post it i'm afraid.


                    any ideas on the above?

                    • 7. Re: Textframe merge or grouping
                      Vamitul Level 4

                      well that's the problem then

                      cFrame = myDocument.pageItems.item("compFrame["+index+"]").getElements()[0];

                      cFrameE = myDocument.pageItems.item("imageFrameE["+index+"]").getElements()[0];

                      cFrameSL = myDocument.pageItems.item("imageFrameSL["+index+"]").getElements()[0];


                      should get you where you need.

                      (a frame with a image is no longer a TextFrame but a Rectangle)

                      • 8. Re: Textframe merge or grouping
                        Xand94 Level 1

                        excellent! the joys of scripting without actually knowing the basics of indesign first!


                        Thanks so much good sir!

                        • 9. Re: Textframe merge or grouping
                          Laubender Adobe Community Professional & MVP

                          Besides naming you could also use the unique ID value of a text frame and address it.

                          Something like that (just an example):


                          //EXAMPLE working with pageItems and ID value
                          //For simplicity all three text frames are selected:
                          //(Not InDesign Server compatible):
                          var d = app.documents[0];
                          //Usually a selected item is already resolved,
                          //so getElements()[0] is not necessary:
                          //Could also be part of a larger selection
                          var id1= app.selection[0].id;
                          var id2 = app.selection[1].id;
                          var id3 = app.selection[2].id;
                          var myGroup = app.layoutWindows[0].activeSpread.groups.add(



                          • 10. Re: Textframe merge or grouping
                            Laubender Adobe Community Professional & MVP

                            And: Be careful in chosing your page items you want to group.

                            All of them have to be positioned on the same spread.


                            And there is this bug with InDesign CC-2014.2 (resolved in CC-2015), if you like to ungroup the objects again:

                            Updated ID CC 2014 with Feb 2015 release, ungrouping objects causes them to vanish



                            • 11. Re: Textframe merge or grouping
                              Xand94 Level 1

                              thanks, I will investigate that method,


                              a little side question but since fixing the above my frames now have these small squares in all 4 corners (each one of the squares inner most corners are missing a pixel or so)


                              Screen Shot 2015-07-24 at 13.50.58.png

                              this could just be something im missing in indesign due to my lack of knowledge, but it wasn't appearing prior to moving the groups..


                              any ideas?

                              • 12. Re: Textframe merge or grouping
                                Laubender Adobe Community Professional & MVP

                                Could be anything.

                                Best would be, if you show a screenshot with item selected and the area or the whole page around it, view options set for visible edges and hidden characters visible.



                                • 13. Re: Textframe merge or grouping
                                  Xand94 Level 1

                                  I have tried the options you mentioned and to no avail.


                                  Unfortunately the artwork in question is from a non released product so I can't actually display the content of the document. essentially it is only 11 textframe/rectangles at present all displaying the same corner marks. if i select one of the items in question i get a blue selection border and the marks are still visible.