Chapter 13. The Section and HeaderFooter Objects

In this chapter:

  • Adding a New Section

  • The PageSetup Object

  • Properties of the Section Object

  • The HeaderFooter Object

The Section object represents a section in a document, range, or selection. Section objects are stored in the Sections collection. Each of the Document, Range, and Selection objects has a Sections property that returns a Sections collection containing the Section objects for that parent.

Adding a New Section

To add a new section to a document, range, or selection, use the Add method of the Sections collection. The syntax is:

SectionsObject.Add(Range, Start)

The optional variant parameter Range refers to a Range object before which the section break will be inserted. If this argument is omitted, the section break is inserted at the end of the document. The optional Start parameter indicates the type of section break. It can be any of the following WdSectionStart constants:

	Enum WdSectionStart
	   wdSectionContinuous = 0
	   wdSectionNewColumn = 1
	   wdSectionNewPage = 2
	   wdSectionEvenPage = 3
	   wdSectionOddPage = 4
	End Enum

The default value is wdSectionNewPage.

As an alternative to the Add method, you can insert a new section using the Insert-Break method, which applies to a Range or Selection object. Its syntax is:

expression.InsertBreak(Type)

where expression refers to either a Range or a Selection object, and Type can be any of the following wdBreakType constants:

 Enum WdBreakType wdSectionBreakNextPage = 2 wdSectionBreakContinuous ...

Get Writing Word Macros, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.