1

ExtendScript を使用して InDesign のスクリプトを作成しようとしています。選択したテキストを切り取って脚注を挿入し、そのテキストを脚注の本文に貼り付けるスクリプトが必要です。私が試したこと:

 function makeFootnoteOfSelection(){
   var fnText = app.activeDocument.selection[0];
         // this should actually clone the selected text, not reference it, because the next statement zaps it from memory
   app.activeDocument.selection[0].remove();  // works
   var fNote = app.activeDocument.selection[0].footnotes.add();  // works, adds an empty footnote with a reference
   fNote.contents = fnText.contents;
         // this replaces the reference number, I was hoping to retain it and just add the text
         // fNote.contents += fnText.contents; also replaces the reference number
}
4

1 に答える 1

5

インデザイン CS5:

function makeFootnoteOfSelection(){

  // Reference the selection
  var fnText = app.activeDocument.selection[0];

  // Add an empty footnote where the selected text is
  var fNote = app.activeDocument.selection[0].footnotes.add();

  // Move the selected text at the end of the empty footnote
  fnText.move(LocationOptions.AFTER, fNote.insertionPoints[-1]);
}

インデザイン CS4:

function makeFootnoteOfSelection(){

  // Reference the selection
  var fnText = app.activeDocument.selection[0];

  //  Position of the text end
  var endPoint = fnText.length - 1;

  // Add an empty footnote where the selected text is
  var fNote = app.activeDocument.selection[0].footnotes.add();

  // Duplicate the selected text at the end of the empty footnote
  fnText.duplicate(LocationOptions.AFTER, fNote.insertionPoints[-1]);

  // Delete the old Text
  fnText.characters.itemByRange(0, endPoint).contents = "";
}
于 2011-02-10T13:28:38.900 に答える