'''' 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 SECTION and SECTIONPAGES field options'' to insert the number of the current section and the number of pages in'' the current section into the document.PublicClassSectionFieldOptsFunctionCreateDocx() AsGcWordDocumentDim doc = NewGcWordDocument() Dim sectionFldOpts = NewSectionFieldOptions(doc) sectionFldOpts.NumberStyle = NumberStyle.UpperRoman Dim sectionPagesFldOpts = NewSectionPagesFieldOptions(doc) sectionPagesFldOpts.NumberFormat = "', '0' page(s)'" Dim rnd = Util.NewRandom()Dim numSections = rnd.Next(3, 6)For i AsInteger = 0To numSections - 1Dim p = doc.Body.AddParagraph("Section ", doc.Styles(BuiltInStyleId.Heading1)) p.AddComplexField(sectionFldOpts) p.AddComplexField(sectionPagesFldOpts)For j AsInteger = 0To rnd.Next(5, 10) - 1Dim par = Util.LoremIpsumPar() doc.Body.AddParagraph(par)NextIf i < numSections - 1Then doc.Body.Paragraphs.Last.AddSectionBreak(SectionStart.Continuous)EndIfNext Dim phdr = doc.Body.Sections.First.Headers(HeaderFooterType.Primary).Body.AddParagraph(doc.Styles(BuiltInStyleId.Closing)) phdr.AddComplexField(NewPageFieldOptions(doc) With {.NumberFormat = "'Page '0"}) doc.UpdateFields(NewGrapeCity.Documents.Word.Layout.WordLayoutSettings() With { .FontCollection = Util.FontCollection, .Culture = CultureInfo.GetCultureInfo("en-US") }) Return docEndFunctionEndClass