PDA

View Full Version : Solved: Multiple choices in a combo box



Chukesgirl
02-06-2006, 01:56 PM
Hi All

I have created a userform in Word 2000, which has a combo box with 15 items. Is there something I can do so that the user can select more than one item from the combo box? Thanks in advance for any help.

Norie
02-06-2006, 02:42 PM
Not easily.:)

Comboboxes aren't really meant for multiple selection.

What exactly do you want to do?

mdmackillop
02-06-2006, 03:05 PM
A ListBox has a multiselect option.

Chukesgirl
02-06-2006, 06:24 PM
The user needs to be able to select about 3 items from a list of 15, but not always. Most of the time they will just select 1 item.

A list box would work for me too. I assume it is set up the same (ListBox.AddItem "xxx"), but how do you select multiple items?

Thanks.

Chukesgirl
02-06-2006, 07:57 PM
I found the MultiSelect option; selected MultiSelectExtended and now I get a runtime error 94, invalid use of null and it's pointing to my bookmark where the selection is supposed to display. Any suggestions?

XLGibbs
02-06-2006, 08:24 PM
By definition, it appears you are trying to pass a variant (designed to contain something) as value, but there nothing contained in the variant....

remember Null is not Empty.

How are you passing the selections to the bookmark?

Chukesgirl
02-07-2006, 10:17 AM
Hello

Please note that I am a novice at VBA---Below is the code that I used for the bookmark. It works if I am only using fmMultiSelectSingle

Private Sub cmdOK_Click()
With ActiveDocument
.Bookmarks("title").Range.Text = ListBox1
End With
Application.ScreenUpdating = True
Unload Me
End Sub

Norie
02-07-2006, 10:23 AM
How are you trying to use it with multiple selections?

Chukesgirl
02-07-2006, 10:37 AM
How are you trying to use it with multiple selections?

That is what I don't know how to do.

mdmackillop
02-07-2006, 11:32 AM
Private Sub UserForm_Initialize()
ListBox1.AddItem "test1"
ListBox1.AddItem "test2"
ListBox1.AddItem "test3"
ListBox1.AddItem "test4"
ListBox1.AddItem "test5"
ListBox1.AddItem "test6"
ListBox1.AddItem "test7"
ListBox1.AddItem "test8"
End Sub

Private Sub ListBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim i As Long
Selection.GoTo What:=wdGoToBookmark, Name:="BM"
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
Selection.TypeText ListBox1.List(i) & vbCr
End If
Next
End Sub

Chukesgirl
02-07-2006, 01:38 PM
Mdmackillop


You are my hero for this month!

Thank you so very much. The code works, so the box works.

mdmackillop
02-07-2006, 01:44 PM
HTH :beerchug:

fumei
02-07-2006, 07:11 PM
I would like to point out that the code does NOT put the text into the bookmark. It only uses the bookmark as a locator. All text is placed after the bookmark, not IN it. If that is not important, then...who cares.

There is easy code that will always place a string INTO a bookmark, regardless of string length, and regardless how how many times you change it.