View Single Post
 
Old 05-23-2024, 05:32 AM
MulaMuster MulaMuster is offline Windows 11 Office 2021
Novice
 
Join Date: May 2024
Posts: 1
MulaMuster is on a distinguished road
Question Listbox with available Building Blocks to choose from

Hi there, I'm struggeling with the following.

I have a Word form with a listbox. I fill this listbox with the available Building Blocks in the template. I wan't to multichoose the items in the listbox and select insert so selected Building Blocks are added to the document. The template with the building blocks and the form is stored on SharePoint using Content Types so i can select this template to start from Sharepoint. It works but not as i want it to work and can't figure it out.

Private Sub cmdList_Click()
Dim objTemplate As Template
Dim objBB As BuildingBlock

Set objTemplate = ThisDocument.AttachedTemplate

With lstFoundBBs
For i = 0 To .ListCount - 1
If .Selected(i) Then
Set objBB = objTemplate.BuildingBlockEntries(lstFoundBBs.Value )
objBB.Insert Selection.Range
End If
Next i
End With
Exit For

End Sub

Keeping error on objTemplate.BuildingBlockEntries(lstFoundBBs.Value ). If I choose objTemplate.BuildingBlockEntries(1) it takes the first Building Block so I need to translate number 1 from the listbox.


I need this to work for all categories.


As alternative I tried the follwing:

Set oBB = Application.Templates(sTempName).BuildingBlockType s(wdTypeAutoText).Categories.Item("MMW").BuildingB locks(sBBName)

I need the Categories.Item("MMW") to be dynamic and working for all categories.

Any help on this will be appreciated.

Thanks.
Reply With Quote