Sections.vb
''
'' This code is part of Document Solutions for Word demos.
'' Copyright (c) MESCIUS inc. All rights reserved.
''
Imports System
Imports System.IO
Imports System.Drawing
Imports GrapeCity.Documents.Word

'' Shows how to add sections to a document.
Public Class Sections
    Function CreateDocx() As GcWordDocument
        Dim doc = New GcWordDocument()

        Dim sec1 = doc.Body.Sections.First
        '' Change default margins from 1" to 1/2":
        With sec1.PageSetup.Margin
            .Left = 36
            .Right = 36
            .Top = 36
            .Bottom = 36
        End With
        Dim pars1 = sec1.GetRange().Paragraphs
        pars1.Add("Section 1, Paragraph 1. " + LoremIpsumPar())
        pars1.Add("Section 1, Paragraph 2. " + LoremIpsumPar())
        pars1.Add("Section 1, Paragraph 3. " + LoremIpsumPar())

        Dim sec2 = doc.Body.Paragraphs.Last.AddSectionBreak()
        '' For the 2nd section, change page orientation:
        sec2.PageSetup.Size.Orientation = PageOrientation.Landscape
        Dim pars2 = sec2.GetRange().Paragraphs
        pars2.Add("Section 2, Paragraph 1. " + LoremIpsumPar())
        pars2.Add("Section 2, Paragraph 2. " + LoremIpsumPar())
        pars2.Add("Section 2, Paragraph 3. " + LoremIpsumPar())

        '' Done:
        Return doc
    End Function
End Class