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.

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 and ContentControl.PlaceholderText.

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

Category

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

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

Delete

Deletes the specified building block.

CustomizationContext.BuildingBlockEntries(1).Delete

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.

The ID property returns an identification string that is in the form of a GUID.

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

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.

Insert (Where, RichText)

Dim objTemplate As Template 
Dim objBB As BuildingBlock 
 
Set objTemplate = Templates(1) 
Set objBB = objTemplate.BuildingBlockEntries(1) 
 
objBB.Insert ActiveDocument.Paragraphs(1).Range

Arguments

The following argument is required

Where (Range) - The location of where to place the contents of the building block.

Optional arguments

The following argument is optional

RichText (String) - True inserts the building block as rich, formatted text. False inserts the building block as plain text.

InsertOptions

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

The value of the InsertOptions property can be any WdDocPartInsertOptions constant.

CustomizationContext.BuildingBlockEntries(1).InsertOptions =

Name

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

CustomizationContext.BuildingBlockEntries(1).Name =

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 =