Class BuildingBlock (Word VBA)

The class BuildingBlock represents a building block in a template. A building block is pre-built content, similar to autotext, that may contain text, images, and formatting.

The main procedures of class BuildingBlock are Delete, BuildingBlockEntries.Add and BuildingBlocks.Add

Set

To use a BuildingBlock class variable it first needs to be instantiated, for example

Dim bbk as BuildingBlock
Set bbk = CustomizationContext.BuildingBlockEntries(Index:=1)

The following procedures can be used to set variables of type BuildingBlock: BuildingBlockEntries.Add, BuildingBlockEntries.Item, BuildingBlocks.Add, BuildingBlocks.Item, ContentControl.PlaceholderText, Template.BuildingBlockEntries and Category.BuildingBlocks

For Each

Here is an example of processing the BuildingBlock items in a collection.

Dim bbkBuildingBlockEntry As BuildingBlock
For Each bbkBuildingBlockEntry In CustomizationContext.BuildingBlockEntries
	
Next bbkBuildingBlockEntry

Themes

The following procedures in this class have been grouped together and are described on a separate theme page

Add with its procedures BuildingBlockEntries.Add and BuildingBlocks.Add

Methods

These are the main methods of the BuildingBlock class

Delete - Deletes the specified building block.

CustomizationContext.BuildingBlockEntries(1).Delete

Other Methods

Insert - Inserts the value of a building block into a document and returns a Range object that represents the contents of the building block within the document.

Dim rngInsert As Range
Set rngInsert = CustomizationContext.BuildingBlockEntries(1).Insert(Where:=)

Properties

Category returns a Category object that represents the category for a building block.

Dim ctgCategory As Category
Set ctgCategory = CustomizationContext.BuildingBlockEntries(1).Category

Description returns or sets a String that represents the description for a building block.

CustomizationContext.BuildingBlockEntries(1).Description =

ID returns a String that represents the internal identification number for a building block.

Dim strID As String
strID = CustomizationContext.BuildingBlockEntries(1).ID

Index returns a Long that represents the position of an item in a collection.

Dim lngIndex As Long
lngIndex = CustomizationContext.BuildingBlockEntries(1).Index

InsertOptions returns or sets a Long that represents how to insert the contents of a building block into a document.

CustomizationContext.BuildingBlockEntries(1).InsertOptions =

Name returns or sets a String that represents the name of a building block.

CustomizationContext.BuildingBlockEntries(1).Name =

Parent returns an object that represents the parent object of the specified BuildingBlock object.

Dim objParent As Object
Set objParent = CustomizationContext.BuildingBlockEntries(1).Parent

Type returns a BuildingBlockType object that represents the type for a building block.

Dim bbtType As BuildingBlockType
Set bbtType = CustomizationContext.BuildingBlockEntries(1).Type

Value returns or sets a String that represents the contents of a building block.

CustomizationContext.BuildingBlockEntries(1).Value =

BuildingBlockEntries.Count returns the number of items in the BuildingBlockEntries collection.

Dim lngCount As Long
lngCount = CustomizationContext.BuildingBlockEntries.Count

BuildingBlockEntries.Parent returns an object that represents the parent object of the specified BuildingBlockEntries object.

Dim objParent As Object
Set objParent = CustomizationContext.BuildingBlockEntries.Parent

BuildingBlocks.Count returns the number of items in the BuildingBlocks collection.

Dim lngCount As Long
lngCount = CustomizationContext.BuildingBlockEntries(1).Category.BuildingBlocks.Count

BuildingBlocks.Parent returns an object that represents the parent object of the specified BuildingBlocks object.

Dim objParent As Object
Set objParent = CustomizationContext.BuildingBlockEntries(1).Category.BuildingBlocks.Parent