多种对象![]() ![]() ![]() |
本对象为 Section 对象组成的集合,这些元素对象位于所选内容、范围或文档中。
可用 Sections 属性返回 Sections 集合。下例在活动文档最后一节的结尾插入文字。
With ActiveDocument.Sections.Last.Range
.Collapse Direction:=wdCollapseEnd
.InsertAfter "end of document"
End With
可用 Add 方法或 InsertBreak 方法在文档中添加新的节。下例在活动文档的开头添加一节。
Set myRange = ActiveDocument.Range(Start:=0, End:=0)
ActiveDocument.Sections.Add Range:=myRange
myRange.InsertParagraphAfter
下例显示活动文档中节的数目,在选定内容的第一段之前插入分节符,并再次显示节的数目。
MsgBox ActiveDocument.Sections.Count & " sections"
Selection.Paragraphs(1).Range.InsertBreak _
Type:=wdSectionBreakContinuous
MsgBox ActiveDocument.Sections.Count & " sections"
可用 Sections(index) 返回单独的 Section 对象,其中 index 为索引号。下例修改活动文档第一节的左、右页边距。
With ActiveDocument.Sections(1).PageSetup
.LeftMargin = InchesToPoints(0.5)
.RightMargin = InchesToPoints(0.5)
End With