设置可用于内容控件的构建基块
文档构建基块是预先设计的内容块,如封面、页眉或页脚。 Word 包含一个文档构建基块库,用户可以选择从中插入到文档中。
ContentControl 对象 (Word) 对象,其 ContentControl.Type 属性 (Word) 属性值 wdContentControlBuildingBlockGallery 指定可包含文档构建基块的内容控件。
WdBuildingBlockTypes 枚举包含每个构建基块类型。 只能在构建基块库内容控件中使用以下构建基块类型:
自动图文集
表格
公式
文档部件
自定义 1 到自定义 5
自定义自动图文集
自定义表格
自定义公式
自定义文档部件
有关内容控件的详细信息,请参阅使用内容控件。 以下示例中所用对象如下:
示例
以下代码示例实例化构建基块库内容控件,然后将构建基块添加到内容控件。
Sub SetBuildingBlock()
Dim strTitle As String
strTitle = "My Equation"
Dim objContentControl As ContentControl
Set objContentControl = ActiveDocument.ContentControls _
.Add(wdContentControlBuildingBlockGallery)
objContentControl.Title = strTitle
objContentControl.BuildingBlockType = wdTypeEquations
End Sub
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。