Section Object

Microsoft Word Visual Basic

Multiple objectsSections
Section
Multiple objects

Represents a single section in a selection, range, or document. The Section object is a member of the Sections collection. The Sections collection includes all the sections in a selection, range, or document.

Using the Section Object

Use Sections(index), where index is the index number, to return a single Section object. The following example changes the left and right page margins for the first section in the active document.

With ActiveDocument.Sections(1).PageSetup
    .LeftMargin = InchesToPoints(0.5)
    .RightMargin = InchesToPoints(0.5)
End With
		

Use the Add method or the InsertBreak method to add a new section to a document. The following example adds a new section at the beginning of the active document.

Set myRange = ActiveDocument.Range(Start:=0, End:=0)
ActiveDocument.Sections.Add Range:=myRange
myRange.InsertParagraphAfter
		

The following example adds a section break above the first paragraph in the selection.

Selection.Paragraphs(1).Range.InsertBreak _
    Type:=wdSectionBreakContinuous
		

Note  The Headers and Footers properties of the specified Section object return a HeadersFooters object.