Get Started
Usage API
More information


AddEndnoteCrossRef(sRefType, oParaTo, [bLink], [bAboveBelow]) → { boolean }

Adds an endnote cross-reference to the current paragraph. The paragraph must be in the document.


Name Type Default Description
sRefType endnoteRefTo

The text or numeric value of an endnote reference you want to insert.

oParaTo ApiParagraph

The first paragraph from an endnote to be referred to (must be in the document).

bLink boolean true

Specifies if the reference will be inserted as a hyperlink.

bAboveBelow boolean false

Specifies if the above/below words indicating the position of the reference should be included (don't used with the "aboveBelow" sRefType).




Copy code
var oDocument = Api.GetDocument();
var oElement = oDocument.GetElement(0);
var nElementCount = oElement.GetElementsCount();
if (nElementCount == 1) {
    var oRun = Api.CreateRun();
    oRun.AddText("Add any endnote to this page. To do this, select any word or word phrase in this sentences, open the References tab, click the arrow next to the Footnote icon and choose the Insert Endnote option from the menu. Enter the endnote text. After that, copy the macro above (without the first and last two lines) and run it (Plugins -> Macros).");
else {
    var aEndNotesFirstParagraphs = oDocument.GetEndNotesFirstParagraphs();
    var oParagraph = Api.CreateParagraph();
    oParagraph.AddText("For more information on previous sentences see endnote on page ");
    oParagraph.AddEndnoteCrossRef("pageNum", aEndNotesFirstParagraphs[0]);
builder.SaveFile("docx", "AddEndnoteCrossRef.docx");

Resulting document