Populate listbox with collection

M

mwalsh62

Hi,

I've managed to fill a combobox with categories using:

With frmAddItems.combCat

For intCount = 1 To objTemplate.BuildingBlockTypes.Count
Set objBBT = objTemplate.BuildingBlockTypes(intCount)
If objBBT.Categories.Count > 0 Then
For intCountCat = 1 To objBBT.Categories.Count
Set objCat = objBBT.Categories(intCountCat)

.AddItem objCat.Name

Next
End If
Next

End With

But I am having trouble making the next step, selecting a category from the
combobox, and filling a ListBox with the resulting BuildingBlocks. I assume
my problem is integer vs. string, and getting the proper syntax. I've gotten
as far as this:

If objCat.BuildingBlocks.Count > 0 Then
For intCountBBs = 1 To objCat.BuildingBlocks.Count
Set objBBs = objCat.BuildingBlocks(intCountBBs)


I am able to use "1 To 1", for example, and narrow down the list, and return
the right values (in Immediate Window), but I can't quite grasp how to set
combobox value as a variable.

Any help appreciated,
Mike
 
M

mwalsh62

Hi again,

I've Got It! A week of "Googling", if you stare at enough code, a light has
to come on sooner or later!

For future generations of Newbies:

Dim objTemplate As Template
'Dim objBBT As BuildingBlockType
'Dim objCat As Category
'Dim objBBs As BuildingBlock
'Dim intCount As Integer
'Dim intCountCat As Integer
'Dim intCountBBs As Integer
'Dim fCat As String
'fCat = frmAddItems.combCat.Value
'
'Set objTemplate = ActiveDocument.AttachedTemplate
'
'With frmAddItems.ListBox1
'For intCount = 1 To objTemplate.BuildingBlockTypes.Count
' Set objBBT = objTemplate.BuildingBlockTypes(intCount)
'
' If objBBT.Categories.Count > 0 Then
' Set objCat = objBBT.Categories(fCat)
'
' If objCat.BuildingBlocks.Count > 0 Then
' For intCountBBs = 1 To objCat.BuildingBlocks.Count
' Set objBBs = objCat.BuildingBlocks.Item(intCountBBs)
' frmAddItems.ListBox1.AddItem objBBs.Name
' Next
' End If
' End If
'Next
'End With
'End Sub




Thanks anyway!
Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top