Hello,
I have a word template for which I have created a userform. The userform has
2 ListBoxes and a commandButton. I want to choose either ListBox1 or
ListBox2, but I failed.
To populate the 2 ListBoxes :
Private Sub UserForm_Initialize()
LisBox1.List = Array("Text1", "Text2", "Text3")
ListBox2.List = Array("Text4", "Text5", "Text6")
End Sub
The CommandButton :
Private Sub CommandButton1_Click()
Selection.InsertAfter UserForm1.ListBox1.Value
Unload Me
End Sub
The last code only works for one ListBox, but I want to choose one listbox.
Doug Robbins - Word MVP - 31 Oct 2005 09:06 GMT
Why wouldn't you use just one listbox containing all of the items?

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Hello,
> I have a word template for which I have created a userform. The userform
[quoted text clipped - 12 lines]
> The last code only works for one ListBox, but I want to choose one
> listbox.
François - 31 Oct 2005 12:14 GMT
Hello,
Because :
- the 2 ListBoxes are completly different
- too many items in each ListBox
Regards
Doug Robbins - Word MVP - 31 Oct 2005 12:52 GMT
But, the information is going into the same place in the document.
Private Sub CommandButton1_Click()
Dim i As Long
i = InputBox("From which ListBox do you want the item inserted (1 or 2
only)")
If i = 1 Then
Selection.InsertAfter ListBox1.Value
ElseIf i = 2 Then
Selection.InsertAfter ListBox2.Value
Else
MsgBox "You must enter either 1 or 2."
End If
End Sub

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Hello,
> Because :
> - the 2 ListBoxes are completly different
> - too many items in each ListBox
> Regards