Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-02-2013, 06:49 AM
paul_pearson paul_pearson is offline Multiple entries in dropdown lists Windows 7 64bit Multiple entries in dropdown lists Office 2010 64bit
Novice
Multiple entries in dropdown lists
 
Join Date: Mar 2013
Posts: 5
paul_pearson is on a distinguished road
Default Multiple entries in dropdown lists

Hi

Can i create a Template with dropdown list of 35 companies to choose from using the following examples to show what i require:

If i select Roundhouse Nurseries or Smithswholesales from the list it also includes Phone Number,Fax Number and Email address for each company....can i have about 35 companies in the dropdown list to choose from....i will only select 1 company at a time as this will be for a invoice (will create a template)....i want it to show the email address but not have the blue underline

Roundhouse Nurseries


Phone: 08 1111 1111
Fax: 08 2222 2222
Email: sales@roundhousenurseries.com.au


Smiths Wholesales
Phone: 08 3333 3333
Fax: 08 4444 4444
Email: sales@smithswholesales.com.au

Thanks

Paul
Excel 2010
Reply With Quote
  #2  
Old 04-02-2013, 08:16 PM
macropod's Avatar
macropod macropod is offline Multiple entries in dropdown lists Windows 7 64bit Multiple entries in dropdown lists Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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 could add the entries to a dropdown content control. As the dropdown only supports a single line per entry, the other data could be output to a plain text or rich text content control via an on_exit macro (i.e. you must exit the dropdown content control after updating it for the conditional output to appear). See attached demo. If you examine the dropdown, you'll see the Client names appear. And, if you examine the dropdown's properties, you'll see that for each client name, the 'Value' field contains the dependent data, with the different output lines separated by | characters, as in:
Phone: 08 1111 1111|Fax: 08 2222 2222|Email: sales@roundhousenurseries.com.au
The code is:
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim i As Long, StrDetails As String
With ContentControl
  If .Title = "Client" Then
  For i = 1 To .DropdownListEntries.Count
    If .DropdownListEntries(i).Text = .Range.Text Then
      StrDetails = Replace(.DropdownListEntries(i).Value, "|", Chr(11))
      Exit For
    End If
  Next
  ActiveDocument.ContentControls(2).Range.Text = StrDetails
  End If
End With
End Sub
To access the macro in the attached document, open it and press Alt-F11.
Attached Files
File Type: zip Content Controls - Dropdown Dependent Text.zip (32.0 KB, 3220 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 04-02-2013, 08:42 PM
rich_cirillo rich_cirillo is offline Multiple entries in dropdown lists Windows 7 64bit Multiple entries in dropdown lists Office 2010 64bit
Novice
 
Join Date: Sep 2012
Posts: 27
rich_cirillo is on a distinguished road
Default

That looks interesting...i could maybe used this for my needs

Rich
Reply With Quote
  #4  
Old 04-02-2013, 09:48 PM
paul_pearson paul_pearson is offline Multiple entries in dropdown lists Windows 7 64bit Multiple entries in dropdown lists Office 2010 64bit
Novice
Multiple entries in dropdown lists
 
Join Date: Mar 2013
Posts: 5
paul_pearson is on a distinguished road
Default

Hi Paul
Looks excellent...i will have a play around later but so far looks great..
Is there a limit on how many entries i can place in the Content Control Dropdown box
If i want to add other lists further down the page such as personal information will i just use the code you supplied or will a further code update be required
Example:
Names: xxxxxxxxxxxx
Credit Card No: xxxxxxxxx
Card type: xxxxxxxxxx
Expiry date: xxxxxxxxxx
Thanks
Paul
Reply With Quote
  #5  
Old 04-02-2013, 11:02 PM
macropod's Avatar
macropod macropod is offline Multiple entries in dropdown lists Windows 7 64bit Multiple entries in dropdown lists Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Quote:
Originally Posted by paul_pearson View Post
Is there a limit on how many entries i can place in the Content Control Dropdown box
If i want to add other lists further down the page such as personal information will i just use the code you supplied or will a further code update be required
I recently set up a process for someone who wanted to add 600 entries to one. Is that enough?

You won't need to make any code changes. Simply add your entries with the names as the content control display name and the other details with pipe separators (ie |) for each line as the content control value. It doesn't even matter if the number of lines vary from one client to the next.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 04-02-2013, 11:12 PM
paul_pearson paul_pearson is offline Multiple entries in dropdown lists Windows 7 64bit Multiple entries in dropdown lists Office 2010 64bit
Novice
Multiple entries in dropdown lists
 
Join Date: Mar 2013
Posts: 5
paul_pearson is on a distinguished road
Default

Hi Paul

Thank you

I think i will have 50

If you have time could you please attach a sample of the "other details with pipe separators (ie |) for each line as the content control value. It doesn't even matter if the number of lines vary from one client to the next"

Would be appreciated

Paul
Reply With Quote
  #7  
Old 03-12-2014, 08:35 AM
Dludwikowski Dludwikowski is offline Multiple entries in dropdown lists Windows XP Multiple entries in dropdown lists Office 2010 32bit
Novice
 
Join Date: Mar 2014
Posts: 1
Dludwikowski is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
You could add the entries to a dropdown content control. As the dropdown only supports a single line per entry, the other data could be output to a plain text or rich text content control via an on_exit macro. See attached demo
Exactly what I want to do as well. Is it possible to do it for multiple content box dropdowns? I have a few different drop down fields that I want to change to the 'value', but when I test it out, it keeps only changing the first one.

Thanks!

Last edited by Dludwikowski; 03-12-2014 at 09:55 AM.
Reply With Quote
  #8  
Old 08-24-2015, 01:10 PM
cole.snavely cole.snavely is offline Multiple entries in dropdown lists Windows 8 Multiple entries in dropdown lists Office 2010 64bit
Novice
 
Join Date: Aug 2015
Posts: 1
cole.snavely is on a distinguished road
Default

Would you be willing to discuss this in more detail with me? Your template is great, just not sure how to edit it to work with my stuff. Thanks so much!

Last edited by macropod; 08-24-2015 at 04:26 PM. Reason: Email address removed for privacy
Reply With Quote
  #9  
Old 02-24-2017, 08:59 AM
ceeaye ceeaye is offline Multiple entries in dropdown lists Windows 10 Multiple entries in dropdown lists Office 2010 64bit
Novice
 
Join Date: Feb 2017
Posts: 1
ceeaye is on a distinguished road
Cool

Quote:
Originally Posted by macropod View Post
You could add the entries to a dropdown content control. As the dropdown only supports a single line per entry, the other data could be output to a plain text or rich text content control via an on_exit macro. See attached demo
Hi there,

Ive attempted to utilize your demo and am having an issue with a new drop down box being added to the doc...

i have a dropdown cc named "Type" with a few choices within. I copied and pasted the dropdown cc onto the second page.

What happens is, my macro runs, the value changes per the macro; however, the first dropdon cc is not changed, the second is changed and a third dropdown cc magically appears.

Perhaps you can assist me with solving my issues? Please let me know.

Many thanks
Reply With Quote
  #10  
Old 07-12-2018, 08:06 AM
tostrand tostrand is offline Multiple entries in dropdown lists Windows 10 Multiple entries in dropdown lists Office 2016
Novice
 
Join Date: Jul 2018
Posts: 4
tostrand is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
You could add the entries to a dropdown content control. As the dropdown only supports a single line per entry, the other data could be output to a plain text or rich text content control via an on_exit macro. See attached demo
I have opened this document and for some reason it doesn't give the information in the second content control. Does it work differently in Word 2016?

We have a form where we want the following:

If "To be processed" is selected in the dropdown list it should on a line below give information "We are including X amount of attachments" where X need to be a textbox.

Since this all is in a form.

Is this possible?

Many thanks

Tanja

Last edited by tostrand; 07-12-2018 at 08:07 AM. Reason: Enter my name
Reply With Quote
  #11  
Old 10-07-2020, 08:57 PM
tripster23 tripster23 is offline Multiple entries in dropdown lists Windows 10 Multiple entries in dropdown lists Office 2013
Novice
 
Join Date: Oct 2020
Posts: 1
tripster23 is on a distinguished road
Default

Hi,

Thank you for this code. In the Content Control Properties > Drop-Down List Properties, is it possible to input more text? The Value field cuts off my text after a certain character limit.
Reply With Quote
  #12  
Old 10-11-2022, 02:47 PM
bil_san1 bil_san1 is offline Multiple entries in dropdown lists Windows 10 Multiple entries in dropdown lists Office 2016
Novice
 
Join Date: Oct 2022
Posts: 12
bil_san1 is on a distinguished road
Default

Hi,

I am new to Macros.. I was able to change the drop down items to and its result.

But I would like to change the First Content Control titles from "Client Details" to "Please Select" and the second Content Control Title from "Client" to "Blank"

I have tried to change in the properties and in the code too but it gives me

Run Time Error "6189"

Also I would like to result to be in other place not close to drop down menu.

Is it possible.

Thanks
Reply With Quote
  #13  
Old 10-11-2022, 03:13 PM
macropod's Avatar
macropod macropod is offline Multiple entries in dropdown lists Windows 10 Multiple entries in dropdown lists Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Quote:
Originally Posted by bil_san1 View Post
But I would like to change the First Content Control titles from "Client Details" to "Please Select" and the second Content Control Title from "Client" to "Blank"

I have tried to change in the properties and in the code too but it gives me

Run Time Error "6189"
You need to change the titles in both the document and the code.
Quote:
Originally Posted by bil_san1 View Post
Also I would like to result to be in other place not close to drop down menu.
The output content control can be located anywhere in the document. If you want different parts of the output going to different content controls, see, for example, post #33 in this thread: https://www.msofficeforums.com/word-...html#post90264.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #14  
Old 10-11-2022, 03:39 PM
bil_san1 bil_san1 is offline Multiple entries in dropdown lists Windows 10 Multiple entries in dropdown lists Office 2016
Novice
 
Join Date: Oct 2022
Posts: 12
bil_san1 is on a distinguished road
Default Please ignore my post. I have found answer in another post of yours. My answer was formfield

Quote:
Originally Posted by macropod View Post
You need to change the titles in both the document and the code.

I have changed in both code and properties box of both content control. It gives me an error when I click out of it. I have attached the file. Kindly have a look and guide me where I am making mistake.

The output content control can be located anywhere in the document. If you want different parts of the output going to different content controls, see, for example, post #33 in this thread: https://www.msofficeforums.com/word-...html#post90264.
I just want the complete result after a break of 1 or two lines.
Attached Files
File Type: docm Content Controls - Dropdown Dependent Text.docm (31.2 KB, 9 views)

Last edited by bil_san1; 10-12-2022 at 02:55 AM. Reason: Found the answer in another post
Reply With Quote
  #15  
Old 03-12-2014, 02:14 PM
macropod's Avatar
macropod macropod is offline Multiple entries in dropdown lists Windows 7 32bit Multiple entries in dropdown lists Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

Yes, that's quite possible. You could, for example, keep adding If ... End If tests to the code for each of the additional content controls. As for the output, you need to make sure the 2 in 'ActiveDocument.ContentControls(2).Range.Text' refers to the correct content control in each case (e.g. you might need to change it to 4 for the second one, and so on).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple entries in dropdown lists Delete Multiple Entries dudeabides Office 1 07-04-2011 02:49 AM
Multiple task lists and multiple calendars kballing Outlook 0 01-18-2011 10:23 AM
Creating Multiple Contact Lists meltee78 Outlook 1 01-03-2011 09:45 PM
multiple calendar entries across a group halfhearted Outlook 0 10-11-2009 12:13 PM
Word Forms : Dropdown lists wferaera45 Word 0 04-06-2006 03:02 AM

Other Forums: Access Forums

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