'''' 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 INDEX and XE field options'' to add an index to a DOCX Word document.PublicClassIndexFieldOptsPrivateShareds_indexWordsAsString() = {"lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit", "mauris", "id", "volutpat","tellus", "ullamcorper", "sem", "praesent", "et", "ante", "laoreet", "lobortis", "nunc", "congue" } FunctionCreateDocx() AsGcWordDocumentDim doc = NewGcWordDocument() ConstNPARSAsInteger = 30For i AsInteger = 0ToNPARS - 1Dim par = doc.Body.Paragraphs.Add()Dim txt = Util.LoremIpsumPar() Dim words = txt.Split(NewChar() {" "c, ","c, "."c}, 2)If words.Length <> 2ThenThrowNew Exception("Unexpected")EndIf Dim word = words(0)Dim xe = NewXeFieldOptions(doc) xe.Entry.Content.Text = word par.AddComplexField(xe) par.AddRun(txt)Next doc.Body.Paragraphs.Last.AddSectionBreak()Dim p = doc.Body.Paragraphs.Add(doc.Styles(BuiltInStyleId.Index1))Dim index = NewIndexFieldOptions(doc) index.Columns = 2 index.Heading = "A"Dim field AsComplexField = p.AddComplexField(index) field.Update(NewGrapeCity.Documents.Word.Layout.WordLayoutSettings() With { .FontCollection = Util.FontCollection, .Culture = CultureInfo.GetCultureInfo("en-US") }) Return docEndFunctionEndClass