Word 2007 - Display autotext entries in userform combo-box

A

Adri

I have a userform which has a combo-box which displays autotext entries. It
works fine, except the autotext entries are not sorted alphabetically...they
seem to be sorted in the order in which I created them. In Word 2000, they
automatically sorted alphabetically. Can anyone tell me how to get them to
sort alpha in 2007?

Thanks...

Following is the 2007 code I'm using.

Dim objDeptAddress As BuildingBlock

For i = 1 To
MyTemplate.BuildingBlockTypes(wdTypeAutoText).Categories("DeptAddress").BuildingBlocks.Count
Set objDeptAddress =
MyTemplate.BuildingBlockTypes(wdTypeAutoText).Categories("DeptAddress").BuildingBlocks(i)
FaxDlg.Address_ComboBox.AddItem objDeptAddress.Name
Next i
 
G

Greg Maxey

Adri,

Yes I think you are right. They appear by index order which is the order
they were created. I had the same problem trying to create a ribbon control
that would list buidling blocks alphabetically. Below is a modification of
the method I used:

Private Sub UserForm_Initialize()
Dim oTmp As Template
Dim arrBB() As String
Dim i As Long
For Each oTmp In Templates
If oTmp.Name = "Text & Image Bank.dotm" Then
Exit For
End If
Next oTmp
ReDim
arrBB(oTmp.BuildingBlockTypes(wdTypeCustomAutoText).Categories("Technical
Terms").BuildingBlocks.Count - 1)
For i = 0 To
oTmp.BuildingBlockTypes(wdTypeCustomAutoText).Categories("Technical
Terms").BuildingBlocks.Count - 1
arrBB(i) =
oTmp.BuildingBlockTypes(wdTypeCustomAutoText).Categories("Technical
Terms").BuildingBlocks(i + 1).Name
Next
On Error Resume Next
WordBasic.SortArray arrBB, 0
On Error GoTo 0
For i = 0 To UBound(arrBB)
Me.ComboBox1.AddItem arrBB(i)
Next i
End Sub

Good luck.
 
A

Adri

Greg, it works! Thank you so much for the help...this is an absolute
lifesaver for me, as I have many categories of autotext displaying in many
userforms, and am constantly adding/deleting autotext in each category. So
having them always sort alpha is critcal to the usability of the userforms.

This may not be the correct forum to say this, but may I also thank you so
much for all the info on your website regarding customizing the Ribbon. It
has been absolutely invaluable to me in converting our 2000 custom menus &
toolbars to an equivalent Ribbon in 2007.

Adri
 
G

Greg Maxey

Glad I could help. Thanks so much for your kinds words. If you will
contact me via the webpage I will send you a little template that you may
find useful for your AutoText.
 
A

Adri

Will do...thank you.

Greg Maxey said:
Glad I could help. Thanks so much for your kinds words. If you will
contact me via the webpage I will send you a little template that you may
find useful for your AutoText.
 

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