Sections.vb
  1. ''
  2. '' This code is part of Document Solutions for Word demos.
  3. '' Copyright (c) MESCIUS inc. All rights reserved.
  4. ''
  5. Imports System
  6. Imports System.IO
  7. Imports System.Drawing
  8. Imports GrapeCity.Documents.Word
  9.  
  10. '' Shows how to add sections to a document.
  11. Public Class Sections
  12. Function CreateDocx() As GcWordDocument
  13. Dim doc = New GcWordDocument()
  14.  
  15. Dim sec1 = doc.Body.Sections.First
  16. '' Change default margins from 1" to 1/2":
  17. With sec1.PageSetup.Margin
  18. .Left = 36
  19. .Right = 36
  20. .Top = 36
  21. .Bottom = 36
  22. End With
  23. Dim pars1 = sec1.GetRange().Paragraphs
  24. pars1.Add("Section 1, Paragraph 1. " + LoremIpsumPar())
  25. pars1.Add("Section 1, Paragraph 2. " + LoremIpsumPar())
  26. pars1.Add("Section 1, Paragraph 3. " + LoremIpsumPar())
  27.  
  28. Dim sec2 = doc.Body.Paragraphs.Last.AddSectionBreak()
  29. '' For the 2nd section, change page orientation:
  30. sec2.PageSetup.Size.Orientation = PageOrientation.Landscape
  31. Dim pars2 = sec2.GetRange().Paragraphs
  32. pars2.Add("Section 2, Paragraph 1. " + LoremIpsumPar())
  33. pars2.Add("Section 2, Paragraph 2. " + LoremIpsumPar())
  34. pars2.Add("Section 2, Paragraph 3. " + LoremIpsumPar())
  35.  
  36. '' Done:
  37. Return doc
  38. End Function
  39. End Class
  40.