Export (0) Print
Expand All

Category Object (Word)

Represents an individual category of a building block type.

Version Added: Word 2007

Microsoft Word uses types and categories to organize building blocks. Each building block type is represented by a WdBuildingBlockTypes constant. Each category is a unique string that a user defines. Word comes with two categories already defined: "General" and "Custom"; you can create additional categories as you need.

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

Use the Item method of the Categories collection to access an exising category; to create a new category, use the Add method of the BuildingBlockEntries collection. Set the value of the Category parameter.

For more information about building blocks, see Working with Building Blocks.

Community Additions

ADD
Show:
© 2014 Microsoft