'''' This code is part of Document Solutions for Word demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.GlobalizationImportsGrapeCity.Documents.WordImportsGrapeCity.Documents.Word.Fields '' This sample shows how to use the NOTEREF field options to add'' and customize a reference to a footnote or endnote marked by a'' bookmark elsewhere in the document. A companion PAGEREF field'' targeting the same bookmark shows that WordLayout can resolve a'' page number for a bookmark anchored to a footnote/endnote mark.PublicClassNoteRefFieldOptsFunctionCreateDocx() AsGcWordDocumentDim doc = NewGcWordDocument() '' The names of the target bookmarks:ConstfnBmkAsString = "fnBookmark"ConstenBmkAsString = "enBookmark" Dim p1 = doc.Body.AddParagraph("See the footnote") p1.GetRange().Footnotes.Add("This is the footnote text.")'' The bookmark must be placed on the paragraph that contains the'' footnote's reference mark -- not on content inside the footnote's'' own body -- for NOTEREF/PAGEREF to be able to resolve it: p1.GetRange().Bookmarks.Add(fnBmk) p1.GetRange().Runs.Add(" and the endnote") p1.GetRange().Endnotes.Add("This is the endnote text.") p1.GetRange().Bookmarks.Add(enBmk) p1.GetRange().Runs.Add(".") '' Add some pages:Dim rnd = Util.NewRandom()Dim i AsInteger = 0DoWhile i < rnd.Next(20, 25) doc.Body.AddParagraph(Util.LoremIpsumPar()) i += 1Loop '' NOTEREF to the footnote, formatted like its own reference mark:Dim noteRefFn = NewNoteRefFieldOptions(doc, fnBmk) With {.Hyperlink = True, .FormatAsReferenceMark = True} doc.Body.AddParagraph("Footnote reference mark: ").AddComplexField(noteRefFn) '' NOTEREF to the endnote, as a plain number instead of its (roman numeral) mark:Dim noteRefEn = NewNoteRefFieldOptions(doc, enBmk) With {.Hyperlink = True, .FormatAsReferenceMark = False} doc.Body.AddParagraph("Endnote number: ").AddComplexField(noteRefEn) '' A PAGEREF to the same footnote bookmark shows that WordLayout can'' now resolve a page number for a bookmark anchored to a footnote mark:Dim pageRefFn = NewPageRefFieldOptions(doc, fnBmk) With {.Hyperlink = True} doc.Body.AddParagraph("The footnote is on page: ").AddComplexField(pageRefFn) '' Update fields using a specific culture: doc.UpdateFields(NewGrapeCity.Documents.Word.Layout.WordLayoutSettings() With { .FontCollection = Util.FontCollection, .Culture = CultureInfo.GetCultureInfo("en-US") }) '' Done:Return docEndFunctionEndClass