Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-22-2024, 03:11 AM
emlynot emlynot is offline Looking to build a list from a dropdown menu Windows 10 Looking to build a list from a dropdown menu Office 2021
Novice
Looking to build a list from a dropdown menu
 
Join Date: Oct 2023
Posts: 5
emlynot is on a distinguished road
Default Looking to build a list from a dropdown menu

Hi all,

I'm looking for code which will allow users to select an option from a dropdown list which then puts the selection below the dropdown. When the next option is selected, it puts that selection beneath the previous one, and so on e.g.

[dropdown with options 1,2,3,4]

(selection results in...)
4


2
1
3
(...or whatever order they were selected).

Hoping someone can point me in the right direction.

Thanks!
Reply With Quote
  #2  
Old 02-23-2024, 06:39 AM
gmaxey gmaxey is offline Looking to build a list from a dropdown menu Windows 10 Looking to build a list from a dropdown menu Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
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

What kind of dropdown list?
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 02-27-2024, 03:06 PM
emlynot emlynot is offline Looking to build a list from a dropdown menu Windows 10 Looking to build a list from a dropdown menu Office 2021
Novice
Looking to build a list from a dropdown menu
 
Join Date: Oct 2023
Posts: 5
emlynot is on a distinguished road
Default

Hi Greg,

I was thinking just a content control dropdown. If there's a better way of doing it, I'm open to that too. I've attached a doc with the type of dropdown and an example of the type of output expected.

Thanks.
Attached Files
File Type: docx Document1.docx (19.9 KB, 9 views)
Reply With Quote
  #4  
Old 02-27-2024, 04:55 PM
gmaxey gmaxey is offline Looking to build a list from a dropdown menu Windows 10 Looking to build a list from a dropdown menu Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
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

If you title your CC "DDLists" and put this in the ThisDocument Module of the VB Project, it will do what your describe when the user exits the CC.


Code:
Option Explicit
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim oRng As Range
  Select Case ContentControl.Title
    Case "DDList"
      Set oRng = ContentControl.Range.Paragraphs(1).Range
      oRng.Collapse wdCollapseEnd
      oRng.InsertAfter ContentControl.Range.Text & vbCr
  End Select
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 02-27-2024, 05:02 PM
gmaxey gmaxey is offline Looking to build a list from a dropdown menu Windows 10 Looking to build a list from a dropdown menu Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
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

Oops, I read your requirement wrong. To append the next value selected to the end of the list you will need a second RichText CC titled "List"


Code:
Option Explicit
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim oRng As Range
  Select Case ContentControl.Title
    Case "DDList"
      Set oRng = ActiveDocument.SelectContentControlsByTitle("List").Item(1).Range
      oRng.Collapse wdCollapseEnd
      oRng.InsertAfter vbCr & ContentControl.Range.Text
  End Select
lbl_Exit:
  Exit Sub
 End Sub

You may find this helpful:


(Pseudo Multi-Select Dropdown Content Controls
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #6  
Old 02-27-2024, 05:04 PM
Guessed's Avatar
Guessed Guessed is offline Looking to build a list from a dropdown menu Windows 10 Looking to build a list from a dropdown menu Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

It would be possible to produce this with a macro on the Content Control but the useability would be awful requiring lots of mouse clicks. I would recommend vba userform with a Listbox like the attached doc. Double click the first line to start the macro which opens the userform then click away.
Attached Files
File Type: docm PickMe.docm (20.8 KB, 6 views)
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #7  
Old 02-27-2024, 05:16 PM
gmaxey gmaxey is offline Looking to build a list from a dropdown menu Windows 10 Looking to build a list from a dropdown menu Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
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

Andrew,


I agree. The requested process and my proposed "basic" solution is not ideal. That is why I posted the link. Your example works well. Thanks.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #8  
Old 02-28-2024, 02:51 AM
emlynot emlynot is offline Looking to build a list from a dropdown menu Windows 10 Looking to build a list from a dropdown menu Office 2021
Novice
Looking to build a list from a dropdown menu
 
Join Date: Oct 2023
Posts: 5
emlynot is on a distinguished road
Default

@Greg, thanks for your input.

@Andrew, thanks for the file sample. If I want to edit the options for selection, so the available options are "duck", "cat", "goat" etc. or longer strings, any idea how I would do that?

Thanks again,

Emlyn.
Reply With Quote
  #9  
Old 02-28-2024, 10:14 PM
Guessed's Avatar
Guessed Guessed is offline Looking to build a list from a dropdown menu Windows 10 Looking to build a list from a dropdown menu Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

If you are going to change the options then you should be specific about what it is you 'really' want. How long are those longer strings going to get?

If you view the VBA code in the Userform, you can edit the following macro to remove the green lines below and replace them with the three lines shown in red below.
Code:
Private Sub UserForm_Initialize()
'  Dim i As Integer
'  With Me.lbox
'    For i = 1 To 10
'      .AddItem "Option " & i
'    Next i
'  End With
  Dim sArr() As String
  sArr = Split("cat|dog|donkey|camel|draught horse and its cart", "|")
  Me.lbox.List = sArr
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #10  
Old 02-29-2024, 07:09 AM
emlynot emlynot is offline Looking to build a list from a dropdown menu Windows 10 Looking to build a list from a dropdown menu Office 2021
Novice
Looking to build a list from a dropdown menu
 
Join Date: Oct 2023
Posts: 5
emlynot is on a distinguished road
Default

Andrew,

That's brilliant. Thanks again for this.

Have a good one!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking to build a list from a dropdown menu Dropdown Menu Dependent on a Previous Drop Down lgsikaffy Word VBA 3 12-14-2018 05:14 PM
Looking to build a list from a dropdown menu Values in dropdown menu disappear when sorting snowboarder2 Excel 7 08-30-2018 09:20 AM
Selection of a dropdown creates another dropdown wih the list krishnamurthy.ka2810 Word VBA 1 04-26-2018 11:44 PM
Looking to build a list from a dropdown menu How can I build figures list and tables list separately lopesdasilva Word 2 05-31-2016 01:30 AM
Looking to build a list from a dropdown menu Auto text after selection from Dropdown menu trainsy Word 2 06-04-2014 04:43 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:16 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