#1
|
|||
|
|||
Content Controls - Dependent Dropdown
Hey guys,
I figured I would join this forum to ask if anyone can help me on a project that I working on for my company's sales department. I am stuck at the final part of the form that will be used for signing on new service agreements. I created a form for the first page that can be filled in with the new client's information, and their information would automatically be transferred to the next page which is a termination of service letter for their current vendor. The last part I need is to have a set of 4 dependent drop-down boxes. First box is the manager's name of the current vendor they are cancelling with. I want this box to be the "master" or "control" box... When any of the 7+/- names that are in the box are selected, the following 3 boxes will be that company's name, then their address, then their phone number. Basically I want the three dependent boxes under the "master" to auto populate the correct information for that company once the one of the dependent boxes are selected. I am horrible with VBA and I honestly had to go online and copy someone else's code just to get two boxes to work. I am getting frustrated! Any advice? Or can any one copy the correct blank VBA code that I can fill in for 4 drop-down boxes? If anyone needs to see the document, please let me know and I can send it to you. Thanks! |
#2
|
||||
|
||||
It sounds like you only need one drop down box and the other three can then be plain text CCs filled from some information source. The trick is deciding where to store the company name, address and phone number.
Do you have a table that lists the relevant information somewhere: Manager; Company; Address; Phone A non-coded method would be to store each of the variable information blocks in a particular building block Gallery and Category and then use a Building Block content control to allow the user to select one to insert all at once. This is actually pretty easy to set up and far easier than trying to solve it with a macro.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#3
|
||||
|
||||
See: https://www.msofficeforums.com/word-...html#post46903 and, for different elements from a selected item to be output to different content controls, see: https://www.msofficeforums.com/word-...tml#post120392
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
|||
|
|||
Quote:
I followed the first link that you sent me and inserted it into my form. Now, every time I go to select an item from the drop down menu, it auto populates the 3 lines of text into every other content control box on form? Any ideas? Can I send you the document and have you take a look at it? Thanks for the swift reply! |
#5
|
||||
|
||||
Can you attach the document to a post with some representative content(delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
Quote:
Let me know what I am doing wrong. Thanks! |
#7
|
||||
|
||||
As coded, the ContentControlOnExit macro you're using outputs all the secondary data to the second content control in the document. Apparently, you have that content control (which appears on the first page), linked to the corresponding content controls on the second page and, for whatever reason, those content controls don't allow line breaks. In any event, given your document's layout, you probably need to use a ContentControlOnExit implementation along the lines of the second link I gave you.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#8
|
|||
|
|||
Quote:
I am still very new to this and would like to complete my template. |
#9
|
||||
|
||||
Try the attached. I had to do a bit of guesswork as to what data goes where, but it should give you something to work from.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#10
|
||||
|
||||
Paul
I think the data was supposed to go into the CC immediately below the drop down. In which case, the code should have been Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) Dim i As Long, StrDetails As String, aCC As ContentControl With ContentControl If .Title = "Current Vendor" 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 For Each aCC In ActiveDocument.SelectContentControlsByTitle("Current Vendor Info") aCC.Range.Text = StrDetails Next aCC End If End With End Sub Once you settle on a method for doing the Vendor info, you will need to address the repeating info so that you don't have to repeat filling out the same info in multiple places such as (Property Name). Greg Maxey has a good tool available to assist with this - see https://gregmaxey.com/word_tip_pages...rol_tools.html
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#11
|
|||
|
|||
Quote:
Quote:
Thanks guys! |
#12
|
||||
|
||||
As I said previously, that's because you're using linked content controls. In any event, it's only the linked content controls with the same title that are getting the duplicate content, not all content controls. And, given your document's structure, that's what I'd have thought was your intention.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#13
|
||||
|
||||
To create a new quick part, go to the end of the document and create the content you want in it. Then select that content (hint: experiment with including the final paragraph mark or not) and choose Insert > Quick Parts > Save Selection to Quick Part Gallery. You name the entry and set Type = Quick Parts, and Category = Vendor and make sure it is saved into the template that I posted.
Some background reading that will be useful to you is https://gregmaxey.com/word_tip_pages..._autotext.html and https://support.office.com/en-us/art...c-98599f16cadc
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
#14
|
|||
|
|||
Simple List + Conditional Dropdown List repeated in Multiple Tables
Dear all,
I would like to create 3 tables, each table containing 2 word dropdown lists "Category" and "Subcategory" (see attached dotm file "Category and Subcategory.dotm") imported from an excel (see attached excel file "Sample Question.xlsm"). "Subcategory" dropdown list is dependent on the "Category" dropdown list. For example, if the user selects "A" under "Category", he will only see options "A1", "A2", "A3", "A4" under the "Subcategory" dropdown list. If the user selects "B" under "Category", he will only see options "B1", "B2", "B3", "B4" etc. All the values in the word dropdown list must be imported from the excel and not hardcoded within the word document. In addition, if the user doesn't require all 3 tables, he can choose to delete 1 or 2 or 3 tables. Appreciate if someone could assist on the VBA codes for this. Thanks! |
#15
|
|||
|
|||
Quote:
Any kind experts can assist me with my query please? Thank you. |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Dependent lists using content control | SJPG | Word VBA | 4 | 01-05-2018 02:21 AM |
Macro to save docx to doc that checks compatibility and converts content controls to static content. | staicumihai | Word VBA | 4 | 10-12-2016 08:23 PM |
Dropdown dependent text | JakeLRL | Word VBA | 7 | 04-07-2016 08:26 AM |
make text form field active dependent on dropdown | Glenn0004 | Word VBA | 1 | 06-23-2015 06:13 PM |
Word drop-down content control dependent display issue | vvcat | Word | 6 | 02-03-2015 11:20 PM |