Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / October 2005

Tip: Looking for answers? Try searching our database.

2 Listboxes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
François - 31 Oct 2005 06:03 GMT
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

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.