返回或设置文档中章节标题的标题级别样式。可以是从 0(零)到 8 之间的一个数字,和从 1 到 9 的标题级别相对应。Long 类型,可读写。
在创建带有章节号的页码之前,文档标题必须应用一个多级符号格式,该格式所使用的样式来源于“项目符号和编号”对话框。若要在 Visual Basic 中进行上述操作,需使用 ApplyListTemplate 方法。
本示例第一部分新建一个文档,添加章标题和分页符,然后用“项目符号和编号”对话框中最后一个多级符号格式来设置文档格式。本示例第二部分向页脚中添加了包含章号的居中页码,一个短线将章号和页码分开。第一级标题用于章号,小写罗马数字用于页码。
Dim intLoop As Integer
Dim hdrTemp As HeaderFooter
Documents.Add
For intLoop = 1 To 5
With Selection
.TypeParagraph
.InsertBreak
End With
Next intLoop
ActiveDocument.Content.Style = wdStyleHeading1
ActiveDocument.Content.ListFormat.ApplyListTemplate _
ListTemplate:=ListGalleries(wdOutlineNumberGallery) _
.ListTemplates(7)
Set hdrTemp = ActiveDocument.Sections(1) _
.Headers(wdHeaderFooterPrimary)
With hdrTemp.PageNumbers
.Add PageNumberAlignment:=wdAlignPageNumberCenter
.NumberStyle = wdPageNumberStyleArabic
.IncludeChapterNumber = True
.HeadingLevelForChapter = 0
.ChapterPageSeparator = wdSeparatorEnDash
End With