'''' This code is part of Document Solutions for Word demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.Collections.GenericImportsSystem.GlobalizationImportsSystem.IOImportsGrapeCity.Documents.WordImportsGrapeCity.Documents.Word.Fields '' This sample shows how to add an RD field to a Word document,'' and specify its options.PublicClassRdFieldOptsFunctionCreateDocx() AsGcWordDocumentConstSubDocCountAsInteger = 3Dim tFnames = NewList(OfString)()For i AsInteger = 1ToSubDocCountDim subDoc = NewGcWordDocument() subDoc.Body.Sections.First.PageSetup.PageNumbering.StartingNumber = i + 1 subDoc.Body.AddParagraph($"Heading from sub-document {i}.", subDoc.Styles(BuiltInStyleId.Heading1)) Dim ta = NewTaFieldOptions(subDoc) ta.Category = 1 ta.LongCitation.Text = $"Table of authorities entry from sub-document {i}."Dim p = subDoc.Body.AddParagraph() p.AddComplexField(ta) p.AddRun($"Table of authorities entry from sub-document {i}.") Dim xe = NewXeFieldOptions(subDoc) xe.Entry.Content.Text = $"Index entry from sub-document {i}" p = subDoc.Body.AddParagraph() p.AddComplexField(xe) p.AddRun($"Index entry from sub-document {i}.") tFnames.Add(Path.GetTempFileName()) subDoc.Save(tFnames.Last())Next Dim doc = NewGcWordDocument() Dim toc = NewTocFieldOptions(doc)Dim h = doc.Body.AddParagraph("Table of Contents", doc.Styles(BuiltInStyleId.Title)) h.AddComplexField(toc) Dim toa = NewToaFieldOptions(doc) doc.Body.AddParagraph("Table of Authorities", doc.Styles(BuiltInStyleId.Title)) h = doc.Body.AddParagraph(doc.Styles(BuiltInStyleId.Title)) h.AddComplexField(toa) Dim index = NewIndexFieldOptions(doc) index.PageNumbers.Separator = vbTab h = doc.Body.AddParagraph("Index", doc.Styles(BuiltInStyleId.Title)) h.AddComplexField(index) For i AsInteger = 1ToSubDocCountDim rd = NewRdFieldOptions(doc) With { .FilePath = ToUri(tFnames(i - 1)).ToString(), .Relative = False } h = doc.Body.AddParagraph() h.AddComplexField(rd)Next doc.UpdateFields(NewGrapeCity.Documents.Word.Layout.WordLayoutSettings() With { .FontCollection = Util.FontCollection, .Culture = CultureInfo.GetCultureInfo("en-US") }) tFnames.ForEach(Sub(f) File.Delete(f))Return docEndFunction PrivateSharedFunctionToUri(pathOrUrl AsString) As UriDim existing As Uri = NothingIf Uri.TryCreate(pathOrUrl, UriKind.Absolute, existing) ThenReturn existingEndIfReturnNew Uri(Path.GetFullPath(pathOrUrl))EndFunctionEndClass