Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Macros in indesign to get copy-paste

New Here ,
Jan 17, 2011 Jan 17, 2011

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...

TOPICS
Scripting
2.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 17, 2011 Jan 17, 2011

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 se

...
Translate
Community Expert ,
Jan 17, 2011 Jan 17, 2011

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 18, 2011 Jan 18, 2011

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"

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 18, 2011 Jan 18, 2011
LATEST

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

Peter

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines