Word) (Sections 对象

一套 所选内容、 范围或文档中的对象。

备注

使用 属性以返回 Sections 集合。 下面的示例在活动文档中的最后一节的末尾插入文本。

With ActiveDocument.Sections.Last.Range 
 .Collapse Direction:=wdCollapseEnd 
 .InsertAfter "end of document" 
End With

使用 添加 方法或 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 对象。 下面的示例更改活动文档中第一节左、 右页边距。

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

方法

名称
Add

属性

名称
Application
Count
Creator
第一
最后一个
PageSetup
Parent

另请参阅

Word 对象模型参考

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。