HeadingStyles 物件(Word)HeadingStyles object (Word)

代表用來編譯圖表目錄或目錄的樣式的HeadingStyle物件的集合。A collection of HeadingStyle objects that represent the styles used to compile a table of figures or table of contents.

備註Remarks

使用 HeadingStyles 屬性可傳回 HeadingStyles 集合。Use the HeadingStyles property to return the HeadingStyles collection. 下列範例會顯示使用中文件內第一個目錄的 HeadingStyles 集合中的項目數。The following example displays the number of items in the HeadingStyles collection for the first table of contents in the active document.

MsgBox ActiveDocument.TablesOfContents(1).HeadingStyles.Count

使用 Add 方法將樣式新增至 HeadingStyles 集合。Use the Add method to add a style to the HeadingStyles collection. 下列範例會在使用中文件的開頭加入目錄,,然後將標題樣式新增至用來建立目錄的樣式的清單。The following example adds a table of contents at the beginning of the active document and then adds the Title style to the list of styles used to build a table of contents.

Set myToc = ActiveDocument.TablesOfContents.Add _ 
 (Range:=ActiveDocument.Range(0, 0), UseHeadingStyles:=True, _ 
 LowerHeadingLevel:=3, UpperHeadingLevel:=1) 
myToc.HeadingStyles.Add Style:="Title", Level:=2

使用HeadingStyles (index),其中 index 是索引編號,可以傳回單一的**HeadingStyle** 物件。Use HeadingStyles (Index), where Index is the index number, to return a single HeadingStyle object. 索引編號代表該樣式的 HeadingStyles 集合中的位置。The index number represents the position of the style in the HeadingStyles collection. 下列範例會新增 (在使用中文件的開頭) 圖表目錄的標題樣式、 所構成,然後顯示 HeadingStyles 集合中的 [第一個樣式的名稱。The following example adds (at the beginning of the active document) a table of figures built from the Title style, and then displays the name of the first style in the HeadingStyles collection.

Set myTOF = ActiveDocument.TablesOfFigures.Add _ 
 (Range:=ActiveDocument.Range(0, 0), AddedStyles:="Title") 
MsgBox myTOF.HeadingStyles(1).Style

請參閱See also

Word 物件模型參考資料Word Object Model Reference

支援和意見反應Support and feedback

有關於 Office VBA 或這份文件的問題或意見反應嗎?Have questions or feedback about Office VBA or this documentation? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.