Add related procedures in class BuildingBlock (Word VBA)

This page presents procedures from class BuildingBlock related to the theme Add: BuildingBlockEntries.Add and BuildingBlocks.Add

BuildingBlockEntries.Add

Creates a new building block entry in a template and returns a BuildingBlock object that represents the new building block entry.

Syntax : expression.Add (Name, Type, Category, Range, Description, InsertOptions)

Dim objTemplate As Template 
Dim objBB As BuildingBlock 
 
Set objTemplate = ActiveDocument.AttachedTemplate 
Set objBB = objTemplate.BuildingBlockEntries.Add("Author Name", _ 
 wdTypeCustomTextBox, "Custom", Selection.Range)

Arguments

The following arguments are required:

Name (String) - Specifies the name of the building block entry. Corresponds to the Name property of the BuildingBlock object.

Type (WdBuildingBlockTypes) - Specifies the type of building block to create. Corresponds to the Type property of the BuildingBlock object.

Here you can find possible values for WdBuildingBlockTypes.

Category (String) - Specifies the category of the new building block entry. Corresponds to the Category property of the BuildingBlock object.

Range (Range) - Specifies the value of the buildling block entry. Corresponds to the Value property of the BuildingBlock object.

The following arguments are optional

Description (String) - Specifies the description of the buildling block entry. Corresponds to the Description property of the BuildingBlock object.

InsertOptions (WdDocPartInsertOptions) - Specifies whether the building block entry is inserted as a page, a paragraph, or inline. If omitted, the default value is wdInsertContent. Corresponds to the InsertOptions property for the BuildingBlock object.

Possible Values are wdInsertContent - Inline building block, wdInsertPage - Page-level building block, wdInsertParagraph - Paragraph-level building block.

BuildingBlocks.Add

Creates a new building block and returns a BuildingBlock object.

Syntax : expression.Add (Name, Range, Description, InsertOptions)

Dim objTemplate As Template 
 
Set objTemplate = Templates(1) 
 
objTemplate.BuildingBlockTypes(wdTypeAutoText) _ 
 .Categories("General").BuildingBlocks _ 
 .Add Name:="New Building Block", _ 
 Range:=Selection.Range

Arguments

The following arguments are required:

Name (String) - Specifies the name of the building block entry. Corresponds to the Name property of the BuildingBlock object.

Range (Range) - Specifies the value of the buildling block entry. Corresponds to the Value property of the BuildingBlock object.

The following arguments are optional

Description (String) - Specifies the description of the buildling block entry. Corresponds to the Description property of the BuildingBlock object.

InsertOptions (WdDocPartInsertOptions) - Specifies whether the building block entry is inserted as a page, a paragraph, or inline. If omitted, the default value is wdInsertContent. Corresponds to the InsertOptions property for the BuildingBlock object.

Possible Values are wdInsertContent - Inline building block, wdInsertPage - Page-level building block, wdInsertParagraph - Paragraph-level building block.