3 Replies Latest reply on Jan 18, 2011 3:38 AM by Peter Kahrel

    Macros in indesign to get copy-paste

    Robin_dv Level 1

      Dear all

      How can we make a macro, which will select the whole paragraph from the current cursor position and copy it again select the next paragraph if we press that key again...

        • 1. Re: Macros in indesign to get copy-paste
          Peter Kahrel Adobe Community Professional & MVP

          I use this script for that:

           

           

           

          try
              {
              if (app.selection[0] instanceof InsertionPoint)
                  {
                  var par = app.selection[0].paragraphs[0];
                  if (par.characters[-1].contents != "\r")
                      par.insertionPoints[-1].contents = "\r";
                  par.duplicate (LocationOptions.after, par.insertionPoints[-1])
                }
             else
                {
                var sel = app.selection[0];
                sel.duplicate (LocationOptions.after, sel.insertionPoints[-1]);
                }
             }
          catch (_){}

           

          With an insertion point selected, it duplicates the current paragraph after itself. If you've selected anything else it duplicates that selection after the selection's last insertion point. In other words, the script mimics the ESTK's Ctrl+D key (going back probably to WordStar). Note that you run the script once: no need for copy and paste.

           

          Peter

          • 2. Re: Macros in indesign to get copy-paste
            Robin_dv Level 1

            Dear Peter,

             

            Thanks for reply but the actual requirement was to select and copy text from the current position of the cursor till the end of the paragraph, and change the position of the cursor to the endpoint of the selected paragraph and not to paste only copy.

             

            for example if my cursor position is after "boy" and before "comma", and run the script than it should select and copy the text

            ",Now he is in america"

            if it again run the script than it should select the next paragraph.

             

            Rabs was a good boy, Now he is in America.

            America is one of the best countries in the world"

            • 3. Re: Macros in indesign to get copy-paste
              Peter Kahrel Adobe Community Professional & MVP

              That script is a pointer to how you could do it.

               

              Peter