O'Reilly logo

Writing Word Macros, Second Edition by Steven Roman PhD

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The PageSetup Object

The Sections collection has a PageSetup property that returns a PageSetup object. Although Microsoft does not say this explicitly, experimentation indicates that the settings of the PageSetup object for the Sections collection are accurate for only those settings that are common to all of the sections in the Sections collection.

For instance, if a document has three sections, each with the left margin setting of 1.25, then the LeftMargin property of the PageSetup object will equal 1.25. However, if the right margins of the three sections are not all the same, then the Right-Margin setting of the PageSetup object will contain an “obviously” invalid value. (On my system, it returns 138,888.9 inches.)

As another example, the SectionStart property of the PageSetup object returns or sets on the type of section break. It can be one of the following constants:

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

Now, if we create a document with three sections, each of which has type wdSectionNewPage, then the code:

	MsgBox Sections.PageSetup.SectionStart

will display the number 2, as expected (wdSectionNewPage=2). On the other hand, if you change the type of one of the sections to, say, wdSectionContinuous, the previous code will display the number 9,999,999!

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required