Thanks in advance.
Naveen.
No, I'm afraid that the ComboBox doesn't allow sorting, so sorting an array
is the only way.
But, presumably you already have the data sorted when the user adds an item,
so you could loop through the current data to figure out where the new item
needs to be placed, and use the optional 'varindex' parameter of the
.AddItem method to add the row at that position.
George
I have cross-posted this to the VBA Userforms news group where you will get
a proper answer.
*My* answer is that any combobox that contains 10,000 choices is unusable,
so you would be better to think of a different method of obtaining your
user's decision :-)
Cheers
This responds to microsoft.public.mac.office.word on Tue, 30 Jul 2002
12:59:55 +0530, "Naveen.A" <nav...@emazines.com>:
I go along with John on this - 10,000 choices is unworkable in a Word
document. You probably should be using a database instead. That would also
simplify the sorting problem.
In Word, the only way to sort the entries in a combobox or listbox is by
loading them into an array, deleting them from the combobox or listbox, sort
the array using the Wordbasic.sortarray command and then set the .List
property of the combobox or the listbox to the sorted array. The code you
need to use is (taken from an existing application where the ListBox is
named TagNumber)
ReDim TagNumberItems(0) As String
For i = 0 to TagNumber.ListCount-1
TagNumberItems(UBound(TagNumberItems))=TagNumber.List(i)
ReDim Preserve TagNumberItems(UBound(TagNumberItems) + 1)
Next i
For i = TagNumber.listCount - 1 to 0 Step -1
TagNumber.RemoveItem(i)
Next i
WordBasic.sortarray TagNumberItems
TagNumber.List() = TagNumberItems
Please post any response to the newsgroups for the benefit of others who may
also be following the thread.
Hope this helps,
Doug Robbins - Word MVP
"John McGhie [MVP - Word]" <jo...@mcghie-information.com.au> wrote in message
news:itscku8pl7v11mc2q...@4ax.com...