View Single Post
 
Old 05-23-2024, 02:29 PM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Code:
Private Sub UserForm_Initialize()
Dim objTemplate As Template
Dim objBB As BuildingBlock
Dim lngBB As Long

Set objTemplate = ThisDocument.AttachedTemplate
  For lngBB = 1 To objTemplate.BuildingBlockEntries.Count
    Set objBB = objTemplate.BuildingBlockEntries(lngBB)
    With ListBox1
      .AddItem
      .List(.ListCount - 1, 0) = objBB.Name
      .List(.ListCount - 1, 1) = objBB.Category.Name
      .List(.ListCount - 1, 2) = objBB.Type.Index
    End With
  Next
End Sub

Private Sub CommandButton1_Click()
Dim objTemplate As Template
Dim objBB As BuildingBlock
Dim i As Long
  Set objTemplate = ThisDocument.AttachedTemplate
  With ListBox1
    For i = 0 To .ListCount - 1
      If .Selected(i) Then
        Set objBB = objTemplate.BuildingBlockTypes(.List(i, 2)).Categories(.List(i, 1)).BuildingBlocks(.List(i, 0))
        objBB.Insert Selection.Range
      End If
    Next i
  End With
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote