新手请教——VB如何获取插入的BuildingBlock内容并删除
大家好,我是刚接触word开发与VBA的菜鸟,手头上有个关于改写现有模板的紧急任务,目的是把原来模板中重复调用的内容用Buildingblock的形式存放并在宏中进行调用。
我已经在word菜单栏中创建了这些buildingblock,category为"MyTask",类型为“QuickParts",并且能够顺利插入这些buildingblock到文档中,代码如下
Public objTemplate As Template
Public objBB As BuildingBlock
Sub InsertExpandCollapseSection
' Set the template to store the building block
Set objTemplate = ActiveDocument.AttachedTemplate
' Access the building block through the type and category
Set objBB = objTemplate.BuildingBlockTypes(wdTypeQuickParts).Categories("MyTask").BuildingBlocks("InsertExpandCollapseSection")
' Insert the building block into the document
objBB.Insert Selection.Range
End Sub
但还有个功能是撤销之前插入的buildingblock(例如上面的InsertExpandCollapseSection),类似于word本身的undo功能,我大概知道应该用数组array作为中间变量去存储插入的内容,但不知道代码该怎么实现?主要不知道该用什么类型的数组以及如何取得插入的buildingblock的内容,请大虾们指点,小女子感激不尽!