Share via


Category オブジェクト (Word)

文書パーツの種類の個々のカテゴリを表します。

注釈

Microsoft Word は、文書パーツの編成に種類とカテゴリを使用します。 各文書パーツは、 WdBuildingBlockTypes クラスの定数で表されます。 各カテゴリは、ユーザーが定義する一意の文字列です。 Word には、既に定義された "標準" と "カスタム" の 2 つのカテゴリがありますが、必要に応じて追加のカテゴリを作成できます。

Use the Type property to access the building block type associated with a specific category. Use the BuildingBlocks property to access the collection of building blocks for a category. The following example prints the type and category names of all the building blocks in the first template to the Immediate Window. (This example assumes that the Immediate Window is visible.)

Dim objTemplate As Template 
Dim objBBT As BuildingBlockType 
Dim objCat As Category 
Dim intCount As Integer 
Dim intCountCat As Integer 
 
Set objTemplate = Templates(1) 
 
For intCount = 1 To objTemplate.BuildingBlockTypes.Count 
 Set objBBT = objTemplate.BuildingBlockTypes(intCount) 
 If objBBT.Categories.Count > 0 Then 
 Debug.Print objBBT.Name 
 For intCountCat = 1 To objBBT.Categories.Count 
 Set objCat = objBBT.Categories(intCountCat) 
 Debug.Print vbTab & objCat.Name 
 Next 
 End If 
Next

既存のカテゴリにアクセスするには、Categories コレクションの Item メソッドを使用します。新しいカテゴリを作成するには、BuildingBlockEntries コレクションの Add メソッドを使用します。 カテゴリ パラメーターの値を設定します。

文書パーツの詳細については、「文書パーツを操作する」を参照してください。

関連項目

Word オブジェクト モデル リファレンス

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。