Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-19-2016, 12:43 PM
ajanson ajanson is offline Multiple Selection Dropdown list Windows 10 Multiple Selection Dropdown list Office 2013
Novice
Multiple Selection Dropdown list
 
Join Date: Aug 2016
Posts: 9
ajanson is on a distinguished road
Default Multiple Selection Dropdown list

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!
Reply With Quote
  #2  
Old 09-19-2016, 03:52 PM
macropod's Avatar
macropod macropod is offline Multiple Selection Dropdown list Windows 7 64bit Multiple Selection Dropdown list Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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
As coded, the selections are simply reported in a message box. Presumably, you'll want to populate a bookmark, table cell, content control or something else but, without knowing exactly how you've defined the destination(s) in the document, only a generic guide can be given.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 09-19-2016, 03:56 PM
gmaxey gmaxey is offline Multiple Selection Dropdown list Windows 7 32bit Multiple Selection Dropdown list Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,421
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #4  
Old 09-19-2016, 05:21 PM
ajanson ajanson is offline Multiple Selection Dropdown list Windows 10 Multiple Selection Dropdown list Office 2013
Novice
Multiple Selection Dropdown list
 
Join Date: Aug 2016
Posts: 9
ajanson is on a distinguished road
Default

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!!!
Reply With Quote
  #5  
Old 09-19-2016, 05:52 PM
macropod's Avatar
macropod macropod is offline Multiple Selection Dropdown list Windows 7 64bit Multiple Selection Dropdown list Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #6  
Old 09-20-2016, 06:26 AM
ajanson ajanson is offline Multiple Selection Dropdown list Windows 10 Multiple Selection Dropdown list Office 2013
Novice
Multiple Selection Dropdown list
 
Join Date: Aug 2016
Posts: 9
ajanson is on a distinguished road
Default sample doc attached

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!
Attached Files
File Type: docx helpdoc.docx (14.3 KB, 125 views)
Reply With Quote
  #7  
Old 09-20-2016, 04:54 PM
macropod's Avatar
macropod macropod is offline Multiple Selection Dropdown list Windows 7 64bit Multiple Selection Dropdown list Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

See attached. You still haven't said, though, what you want done with the selected items.
Attached Files
File Type: docm helpdoc.docm (25.8 KB, 338 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 09-21-2016, 06:54 AM
ajanson ajanson is offline Multiple Selection Dropdown list Windows 10 Multiple Selection Dropdown list Office 2013
Novice
Multiple Selection Dropdown list
 
Join Date: Aug 2016
Posts: 9
ajanson is on a distinguished road
Default

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!
Reply With Quote
  #9  
Old 09-21-2016, 02:37 PM
macropod's Avatar
macropod macropod is offline Multiple Selection Dropdown list Windows 7 64bit Multiple Selection Dropdown list Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #10  
Old 09-22-2016, 06:59 AM
ajanson ajanson is offline Multiple Selection Dropdown list Windows 10 Multiple Selection Dropdown list Office 2013
Novice
Multiple Selection Dropdown list
 
Join Date: Aug 2016
Posts: 9
ajanson is on a distinguished road
Default

Thank you so very much macropod - it worked fine. I really do appreciate all of your help. Have a wonderful day!
Reply With Quote
  #11  
Old 07-11-2017, 08:35 PM
Chiku Chiku is offline Multiple Selection Dropdown list Windows Vista Multiple Selection Dropdown list Office 2016
Novice
 
Join Date: Jul 2017
Posts: 1
Chiku is on a distinguished road
Default Does not save the selection

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.
Reply With Quote
  #12  
Old 07-11-2017, 08:58 PM
macropod's Avatar
macropod macropod is offline Multiple Selection Dropdown list Windows 7 64bit Multiple Selection Dropdown list Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #13  
Old 02-27-2018, 01:54 AM
ms868 ms868 is offline Multiple Selection Dropdown list Windows 7 64bit Multiple Selection Dropdown list Office 2016
Novice
 
Join Date: Feb 2018
Posts: 5
ms868 is on a distinguished road
Default Selected entried into list

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
Reply With Quote
  #14  
Old 02-27-2018, 02:25 AM
macropod's Avatar
macropod macropod is offline Multiple Selection Dropdown list Windows 7 64bit Multiple Selection Dropdown list Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

In the example I posted, the selected items in the list are highlighted; there is no 'prompting', as such.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #15  
Old 02-27-2018, 03:20 AM
ms868 ms868 is offline Multiple Selection Dropdown list Windows 7 64bit Multiple Selection Dropdown list Office 2016
Novice
 
Join Date: Feb 2018
Posts: 5
ms868 is on a distinguished road
Default

Alright.

Sorry for using the wrong words. I'm completely new to VBA, or coding in general! I don't know the syntax.

Your example was very neat, and i've been trying to adapt to my needs. I have tried to read about this. Often "UserForms" are mentioned, but i don't know how to use those either.

I've figured out the very basic stuff, like changing the selection type from "Multi" to "Extended", and change the list entries, but other than that i'm stuck.

Is there a simple way to have the selected entries listed in a table column?
Either adapting the number of rows to the number of selected items, or by just having enough row lines.

It would simply make my day!

Best regards,

Martin
Reply With Quote
Reply

Tags
form, multi drop down

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Selection Dropdown list Change color according with dropdown selection spk Word VBA 43 07-31-2022 03:51 PM
Multiple Selection Dropdown list 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
Multiple Selection Dropdown list Dropdown selection value coconutt Word VBA 5 09-13-2012 05:23 PM
Multiple Selection Dropdown list Autofill a form which is contingent on a dropdown selection. biffle0764 Word 2 05-09-2012 12:54 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:03 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft