![]() |
|
|
|
#1
|
|||
|
|||
|
Hello,
How do i insert a multiple selection dropdown list into my document? I have already inserted the listbox, and changed the multi-select to 2, but i have no idea what code to use. I just want the user to be able to select 1 or all options that i listed when completing the form. Thank you for your help! |
|
#2
|
||||
|
||||
|
You might use code along the lines of:
Code:
Private Sub CommandButton1_Click()
Dim i As Long, StrOut As String
For i = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(i) Then
StrOut = StrOut & Me.ListBox1.List(i) & vbCr
End If
Next i
MsgBox StrOut
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#3
|
|||
|
|||
|
As for "How do I insert ...," it sounds like you have already achieved that. If you want to populate it then something like this:
Code:
Sub Document_new()
With ListBox1
.Clear
.MultiSelect = fmMultiSelectExtended
.AddItem "A"
.AddItem "B"
.AddItem "C"
.AddItem "D"
End With
End Sub
|
|
#4
|
|||
|
|||
|
Thank you so much for your resbonse, but i'm very new to VBA and i'm lost (i appologize!) but so far this is what i did:
1. I inserted from the developer tab under activex the listbox 2. Went to properties and changed the multi-select to 2. 3. Went to view code...... now what? ![]() I pasted this and then turned design mode off, but there was no list. If you can give me any pointers i would greatly appreciate. Sorry!!! |
|
#5
|
||||
|
||||
|
Perhaps you could attach a document to a post with some representative data (delete anything sensitive) and your form, plus a description of what you want to have happen? You can attach a document to a post via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#6
|
|||
|
|||
|
You can see that i used checkboxes instead, but i would rather have all of these types of services listed in a dropdown so the user is able to select multiple options. I inserted the dropdown beside so you can see. I'm just not sure what's next.
Thank you! |
|
#7
|
||||
|
||||
|
See attached. You still haven't said, though, what you want done with the selected items.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#8
|
|||
|
|||
|
Quote:
Edit: Probably should have added, the list is on a userform and does not contain any external data. |
|
#9
|
|||
|
|||
|
I've just registered here as I'm trying to find a way to do the multi-select drop down in Word 2016 myself and am looking for options. I've downloaded your "helpdoc.docm" which is useful, but doesn't give me what I want exactly. I hope you can help?
I think the best option for me, based on what I've read so far is to use a userform with a drop down on it. What I need to do is be able to: 1. Select a cell within a table in Word, 2. Have the form / drop down list pop up, 3. Select 1 or more options from the list, 4. Confirm and enter those choices into the table as text. 5. need to be able to re-select again by clicking in the cell (if possible)? Would there be any change of getting another helpdoc.docm posted with the basics and code. Doesn't need to be pretty, I can format, etc. Regards, Steve. |
|
#10
|
|||
|
|||
|
Hello, Thank you very much. This is exactly what I was looking for, I just simply wanted to have a multiple-selection dropdown list using the types of services that I had in the checkboxes.
Only one problem though, when i open it I get an error in the code screen "Compile error Only valid in object module" - is there anyway around this? I really just want to copy what you did here and insert it into my doc Thank you so so much!
|
|
#11
|
||||
|
||||
|
I don't get that error when I open the document. Did you make any changes to it? You might also try repairing the Office installation (via Start > Windows Control Panel > Programs > Programs & Features > Microsoft Office (version) > Change > Repair).
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#12
|
|||
|
|||
|
Thank you so very much macropod - it worked fine. I really do appreciate all of your help. Have a wonderful day!
|
|
#13
|
|||
|
|||
|
But the worry is it does not store the selection once you close the file. Any luck how the selection/s could be saved for next session.
|
|
#14
|
||||
|
||||
|
That is by design (i.e. that's a necessary limitation of using ActiveX controls). If you want to save the selection(s) for a later session, you would need to modify the code to both store those selections (e.g. in the document body or metadata) and re-select them after re-populating the ListBox.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#15
|
|||
|
|||
|
Hi
Is it possible to make the selected words from the dropdown appear in a list, instead of prompting, like in the example above? Best regards Martin |
|
| Tags |
| form, multi drop down |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Change color according with dropdown selection
|
spk | Word VBA | 43 | 07-31-2022 03:51 PM |
Auto text after selection from Dropdown menu
|
trainsy | Word | 2 | 06-04-2014 04:43 AM |
| block selection in dropdown list | Intruder | Excel | 2 | 01-10-2013 10:20 AM |
Dropdown selection value
|
coconutt | Word VBA | 5 | 09-13-2012 05:23 PM |
Autofill a form which is contingent on a dropdown selection.
|
biffle0764 | Word | 2 | 05-09-2012 12:54 PM |