Forums     Knowledge Base     OfficeWriter Online     
 
 
This documentation is for
OfficeWriter v3.8.1
.NET Platform

View Docs for Another
Version or Platform

Programmer's Reference > WordApplication API > Section

The Section Object

     extends Element



This class is used to represent a section of the document. Many documents will only contain one section. More complex documents will divide the document into multiple sections. A section can be roughly correlated to a chapter in a book. Each section can have different formatting settings, including:

  • Margins
  • Paper size or orientation
  • Paper source for a printer
  • Page borders
  • Vertical alignment
  • Headers and footers
  • Columns
  • Page numbering
  • Line numbering
  • Footnotes and endnotes

To create a new section, use Element.CreateSectionBefore().

To get an existing section, use Document.Sections.

The following sample shows you how to get the add a new section to a document and how to get the first section of a document.



Examples:

[csharp]
// Add a new section to a document
WordApplication app = new WordApplication();
Document doc = app.Open(@"C:\sample.doc");
Section sect = doc.CreateSectionAfter();

// Get the first section of a document
WordApplication app = new WordApplication();
Document doc = app.Open(@"C:\sample.doc");
Section sec1 = doc.Sections[0]; 
[vbnet]
' Add a new section to a document
Dim app As New WordApplication()
Dim doc As Document = app.Open("C:\sample.doc")
Dim sect As Section = doc.CreateSectionAfter()

' Get the first section of a document
Dim app As New WordApplication()
Dim doc As Document = app.Open("C:\sample.doc")
Dim sect As Section = doc.Sections(0)


Please note that this object inherits methods and properties not shown here from the following objects:

Section Enumerations

NameDescription
Section.BorderArea

Areas that a border can be applied to for a section

Section.BreakType

Types of breaks that can preceed a section

Section.HeaderFooterType

Types of headers and footers

Section.LineNumbering

Line numbering settings for a section

Section.NumberFormat

Formats for page numbers in a section

Section.Orientation

Page orientations for a section

Section.PagePaperSize


Section Properties

Property Type Access Description
Border Border read

Returns a Border object that represents the border of this section at the specified location

BorderAlwaysInFront boolean read
write

Sets or returns a boolean that represents whether or not page borders for this section will always display in front of any objects it may overlap

BorderAppliedTo BorderArea read
write

Sets or returns a BorderArea object that represents where the page border will be applied to

BorderOffsetsFromPage boolean read
write

Sets or returns a boolean that represents whether or not the padding for this section's page border will be measured from the edge of the page or from the text it surrounds

BottomMargin int read
write

Sets or returns an int that represents the vertical distance of the bottom margin from the bottom edge of the page for this section

Break Section.BreakType read
write

Sets or returns a Section.BreakType object that represents the type of break (before) this section

FirstLineNum int read
write

Sets or returns an int that represents the number that the line numbering starts at for this section

FirstPageNum int read
write

Sets or returns an int that represents the number that the page numbering starts at for this section

Footer Element read

Returns an Element object that represents the footer of the specified type for this section

FooterY int read
write

Sets or returns an int that represents the y coordinate of the footer measured from the top edge of the page

GutterWidth int read
write

Sets or returns an int that represents the gutter width for this section

HasTitlePage boolean read
write

Sets or returns a boolean that represents whether or not this section has a title page

Header Element read

Returns an Element object that represents the header of the specified type for this section

HeaderY int read
write

Sets or returns an int that represents the y coordinate of the header measured from the top edge of the page

LeftMargin int read
write

Sets or returns an int that represents the horizontal distance of the left margin from the left edge of the page for this section

LineNumbering Section.LineNumbering read
write

Sets or returns a Section.LineNumbering object that represents the line numbering restart policy for this section

LineNumberX int read
write

Sets or returns an int that represents the x position of line numbers in twips

LineNumModulus int read
write

Sets or returns an int that represents the line numbering modulus

LinesBetween boolean read
write

Sets or returns a boolean that represents whether or not Word will draw vertical lines between columns

NumColumns int read
write

Sets or returns an int that represents the number of columns in this section

PageHeight int read
write

Sets or returns an int that represents the page height for this section in twips

PageNumberFormat Section.NumberFormat read
write

Sets or returns a Section.NumberFormat object that represents the page number format for this section

PageOrientation Section.Orientation read
write

Sets or returns a Section.Orientation object that represents the page orientation for this section

PageSize int read
write
Sets or returns the size of printed pages.
PageWidth int read
write

Sets or returns an int that represents the page width for this section in twips

RestartPageNum boolean read
write

Sets or returns a boolean that represents whether or not page numbering will restart at the beginning of this section

RightMargin int read
write

Sets or returns an int that represents the horizontal distance of the right margin from the right edge of the page for this section

TopMargin int read
write

Sets or returns an int that represents the vertical distance of the top margin from the top edge of the page for this section

Unlocked boolean read
write

Sets or returns a boolean that represents whether or not this section is unlocked



This object does not have any methods defined.



Copyright 2007 © SoftArtisans, Inc. All Rights Reserved.