1

In javascript, I wish to insert a call to insertContentControl() at the very end of the document, after any text in the main body. I thought I could do it with:

      context.document.getSelection();
      var cc = context.document.body.insertContentControl();
      cc.color = 'orange';
      cc.tag = 'wikindx-bibliography';
      cc.title = 'Bibliography';
      cc.insertHtml('A reference', "End");

But that simply incorporates existing text in the content control then appends 'A reference' to the content control.

1 Answers1

0

This works . . .

      context.document.body.paragraphs.getLast().select("End");
      var sel = context.document.getSelection();
      sel.insertParagraph('', "After");
      sel.insertParagraph('', "After");
      context.document.body.paragraphs.getLast().select("End");
      sel = context.document.getSelection();
      var cc = sel.insertContentControl();
      cc.color = 'orange';
      cc.tag = 'wikindx-bibliography';
      cc.title = 'Bibliography';
      cc.insertHtml('A reference', "End");

(With a couple of empty paragraphs as spacers.)