View Single Post
 
Old 02-13-2016, 07:02 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
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

pt,

That won't change the fact that the combobox list column limite is 2047 characters (or at least appears so) or help explain why you would want to put the value of a building block in a combobox column. What is your ultimate goal? If it is to insert building block content into a document then I think you are going about it in the wrong way.

Consider:

Note: Obviously I am not using your template, using AutoText (9) vice CustomAutoText, and my categories are "General" and "Signatures"



Code:
Option Explicit
Dim objTemplate As Template
Private Sub UserForm_Initialize()
  With ComboBox1
    .AddItem "General"
    .AddItem "Signatures"
  End With
lbl_Exit:
  Exit Sub
End Sub
Private Sub ComboBox1_Change()
Dim lngIndex As Long
Dim oBB As BuildingBlock
Dim oCat As Category
  'Set objTemplate = Templates(Environ("APPDATA") & "\Microsoft\Word\STARTUP\ReportMacros.dotm")
  Set objTemplate = Templates(ThisDocument.AttachedTemplate.FullName)
  ComboBox2.Clear
  Set oCat = objTemplate.BuildingBlockTypes(9).Categories(ComboBox1)
  For lngIndex = 1 To oCat.BuildingBlocks.Count
    Set oBB = oCat.BuildingBlocks(lngIndex)
    With ComboBox2
      .AddItem
      .List(.ListCount - 1, 0) = oBB.Name
      .List(.ListCount - 1, 1) = oBB.Type.Index
      .List(.ListCount - 1, 2) = oBB.Category.Name
    End With
  Next lngIndex
  ComboBox2.Text = ComboBox2.List(0)
lbl_Exit:
  Exit Sub
End Sub
Private Sub CommandButton1_Click()
  objTemplate.BuildingBlockTypes(ComboBox2.Column(1)).Categories(ComboBox2.Column(2)).BuildingBlocks(ComboBox2.Column(0)).Insert Where:=Selection.Range, RichText:=True
  Hide
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote