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!
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access