7 Replies Latest reply on Oct 28, 2016 4:40 AM by williamadowling

    New Area Text

    Djos Level 1

      Hello everyone, on this occasion I have a scrit, It can create a new text area, that is selected, ready for editing.

      like this

      This script:


      var myPathItem1 = myDoc.pathItems.rectangle(200,75,500,300);

      var myTextFrame1 = myDoc.textFrames.areaText(myPathItem1);



      creates the area text but not selected for editing.



      Any suggestions?


        • 1. Re: New Area Text
          Silly-V Adobe Community Professional

          Wow, I tried to mess with it- and couldn't find a solution at this time. It looks like the only way to get your cursor is to explicitly have the type tool active and clicking on the text box.

          1 person found this helpful
          • 2. Re: New Area Text
            williamadowling Level 4

            i found the same result, silly.


            I suppose one solution would be to set a variable to the result of a prompt or some other type of user input and then just set the contents of the area text frame to the variable.


            var myPathItem1 = myDoc.pathItems.rectangle(200,75,500,300);

            var myTextFrame1 = myDoc.textFrames.areaText(myPathItem1);

            myTextFrame1.contents = prompt("Enter the text for myTextFrame1","");

            • 3. Re: New Area Text
              Djos Level 1

              okay. I try to do is something like "JoinTextFrames", but this time I have a group with texts, when I copy and paste the group in a area text.




              the texts come together.


              and I have many groups of text, I thought about creating a script to join texts

              For the moment this is my script..





              var myDoc =  app.activeDocument;

              var width=app.activeDocument.selection[0].width;

              var height=app.activeDocument.selection[0].height;

              var xy=app.activeDocument.selection[0].position;


              var re = /(.*\d+\.*\d*),(.*\d+\.*\d*)/;

              var str = xy;

              var newstrY = str.replace(re, "$2");

              var newstrX = str.replace(re, "$1");




              var myPathItem1 = myDoc.pathItems.rectangle(newstrY,newstrX,width,height);

              var myTextFrame1 = myDoc.textFrames.areaText(myPathItem1);




              what it does is copy the text group, and as is selected, acquires its property (x, y, w, h) and uses them to create an area text, but I can not paste the text in the new area text.


              then would have to find a way to select text groups, one at a time and insert them into the new area texts, that script have created.



              • 4. Re: New Area Text
                o-marat Level 3

                It`s quite another question for the new topic.

                • 5. Re: New Area Text
                  pixxxel schubser MVP & Adobe Community Professional



                  I think this based on the same question.

                  Djos, you can do something like this

                  var myDoc =  app.activeDocument;
                  if (myDoc.selection.length > 0) {
                      var aSel = myDoc.selection[0];
                      var wdt = aSel.width;
                      var hgt = aSel.height;
                      var xy = aSel.position;
                      if (aSel.typename == "TextFrame") {
                          var aCon = aSel.contents;
                          var newX = xy[0];
                          var newY = xy[1];
                          //alert(newY+newX+ wdt+ hgt);
                          var myPathItem1 = myDoc.pathItems.rectangle(newY, newX, wdt, hgt);
                          var myTextFrame1 = myDoc.textFrames.areaText(myPathItem1);
                          myTextFrame1.contents = aCon+ "  [[copied text frame]]";


                  Have fun


                  1 person found this helpful
                  • 6. Re: New Area Text
                    Djos Level 1

                    thanks for the help, for the moment, I thought of another solution, but need to add a selection more:

                    The following script creates a new text area with dimensions of a group of selected text, at the end, the group still is selected text but the new area text is not selected,



                    var myDoc =  app.activeDocument;

                    var width=myDoc.selection[0].width;

                    var height=myDoc.selection[0].height;

                    var xy=myDoc.selection[0].position;

                    var newX = xy[0];

                    var newY = xy[1];

                    var myPathItem1 = myDoc.pathItems.rectangle(newY,newX,width,height);

                    var myTextFrame1 = myDoc.textFrames.areaText(myPathItem1);




                    Is it possible also select the new area text?


                    thus would have the group and the area text selected.



                    PD: I tryed to select by layer name, but I presents the error:

                    No such element



                    var myLayer = layers["Target Layer"];

                    • 7. Re: New Area Text
                      williamadowling Level 4

                      You never declared the variable "layers". On it's own, 'layers' isn't an element. It's a property of the document object. try this:


                      var docRef = app.activeDocument;

                      var layers = docRef.layers;

                      var myLayer = layers["Target Layer"];



                      I don't know whether that will fix your selection issue, but that's likely why you got the "No Such Element" error.