4 Replies Latest reply on Jun 21, 2010 6:15 AM by Om...

    copy paste problem

    Om...

      Hi All,

       


      I want to copy some blocked (selected) text and create new text frame with some content, then paste the copied content at the end of newly created created frame.

       

      This is my try.

      --------------------


      app.copy();
      newFrame = app.activeDocument.pages[1].textFrames.add({geometricBounds:[20,30,40,50]});

      newFrame.contents = "some text";
      app.paste();

       

       

      The above code creates new text frame with given text but pasting the copied text in a new frame. Please help me how to paste the copied content at the end of same frame.

       

       

      Thanks in Advance

      Shiv

        • 1. Re: copy paste problem
          Peter Kahrel Adobe Community Professional & MVP

          app.copy();
          newFrame = app.activeDocument.pages[1].textFrames.add({geometricBounds:[20,30,40,50]});

          newFrame.insertionPoints[0].select();
          app.paste();

           

          Have you considered using the duplicate() method?

           

          Peter

          • 2. Re: copy paste problem
            Om... Level 1

            Hi Peter,

             

            Thanks for you quick reply, and i used duplicate method but it shows some error when i select the table cell or row.

             

            myDocument = app.activeDocument;
            temp = myDocument.pages[3].textFrames.add({geometricBounds:[20,30,40,50], contents:"some text"});
            app.selection[0].duplicate (LocationOptions.after, temp.paragraphs.item(0).words.item(0));

             

            The error which i received is app.selection[0].duplicate is not a function. Please help me.

             

             

             

            Thanks in Advance

            Baskar K

            • 3. Re: copy paste problem
              Peter Kahrel Adobe Community Professional & MVP

              You can't duplicate a row or a cell to a text frame, but you can try to duplicate their Text object, you'd have to look into that.

               

              In the meantime, to get your script going with copy and paste, you do this:

               

              app.copy();
              newFrame = app.activeDocument.pages[1].textFrames.add({geometricBounds:[20,30,40,50], contents: "Some text"});

              newFrame.insertionPoints[-1].select();
              app.paste();

               

              This is slightly different than the other version: insertionPoints[-1].select()  selects the last insertion point in the frame.

               

              Peter

              • 4. Re: copy paste problem
                Om... Level 1

                Hi Peter

                 

                I got the required output. Thank you so much .

                 

                 

                Regards

                Shiv