HeadingLevelForChapter Property
Applies To
PageNumbers collection object.
Description
Returns or sets the heading level style that's applied to the chapter titles in the document. Can be a number from 0 (zero) through 8, corresponding to heading levels 1 through 9. Read/write Long.
Remarks
Before you can create page numbers that include chapter numbers, the document headings must have a numbered outline format applied that uses styles from the Bullets and Numbering dialog box. To do this in Visual Basic, use the ApplyListTemplate method.
See Also
ApplyListTemplate method, ChapterPageSeparator property, IncludeChapterNumber property.
Example
The first part of this example creates a new document, adds chapter titles and page breaks, and then formats the document by using the fifth numbered outline format listed in the Bullets and Numbering dialog box. The second part of the example adds centered page numbers — including the chapter number to the footer; an en dash separates the chapter number and the page number. The first heading level is used for the chapter number, and lowercase roman numerals are used for the page number.
Documents.Add
For i = 1 To 5
With Selection
.TypeText "Chapter Number " & i
.TypeParagraph
.InsertBreak
End With
Next i
ActiveDocument.Content.ListFormat.ApplyListTemplate _
ListTemplate:=ListGalleries(wdOutlineNumberGallery).ListTemplates(5)
Set myFoot = ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary)
With myFoot.PageNumbers
.Add PageNumberAlignment:= wdAlignPageNumberCenter
.NumberStyle = wdPageNumberStyleLowercaseRoman
.IncludeChapterNumber = True
.HeadingLevelForChapter = 0
.ChapterPageSeparator = wdSeparatorEnDash
End With