Word 2007: Get a list of building blocks?

3.5k views Asked by At

I'm wordering if there is a way (directly or using VBA) to get a list of all the building blocks as they appear in the Building Blocks Organizer, that is, the names of the building blocks, the Gallery, the Category, the Template, the Behavior, etc. I don't want to extract auto text parts or anything like that. I just want to be able to get and print the complete list of Bilding Blocks and the rest of the info dispayed in the Building Blocks Organizer.

Thanks a lot! D

1

There are 1 answers

3
Dirk Vollmar On

Building block entries are stored within several Word template files. If you want to iterate over all available building blocks, you must therefore iterate over all loaded Word templates. You can do so using the following macro:

Sub ListBuildingBlocks()

    Dim oTemplate As Template
    Dim oBuildingBlock As BuildingBlock
    Dim i As Integer

    For Each oTemplate In Application.Templates
        For i = 1 To oTemplate.BuildingBlockEntries.Count
            Set oBuildingBlock = oTemplate.BuildingBlockEntries.item(i)
            Debug.Print oBuildingBlock.Name + vbTab _
                + oBuildingBlock.Type.Name + vbTab _
                + oBuildingBlock.Category.Name + vbTab _
                + oTemplate.FullName
        Next
    Next

End Sub