#1
|
|||
|
|||
Link CC dropdown to dependent dropdown AND text box
I'm very new at this. Before 3 days ago I hadn't worked with VBA at all, so please bear with me as I try to explain what I'm trying to do.
I'm creating a template, and what I'd like to do is 1. have a primary content control dropdown list, 2. have a dependent dropdown, 3. and a dependent text box that auto-populates **Also, the three content controls are not successive (there's a date picker right after the primary CC). I know how to create a primary CC dropdown with dependent dropdown, and I know (conceptually) how to create a CC dropdown with a text box that auto-populates based on on the CC's Value. Is it possible to have all three? Please see attached additional details. Any help is MUCH appreciated as I fear racking my brain any longer might cause me to spontaneously combust. |
#2
|
|||
|
|||
Just map your primary CC to a customXMLPart then add a plain text CC mapped to the same node. You said you already know how to do the dependent CC piece.
|
#3
|
|||
|
|||
Hi Greg,
I've learned what I do know from here and your website. But maybe I got a bit ahead of myself, and here's where I'm really going to show my newbie-ness...I know zero about XML parts. I've been able to create primary/dependent dropdowns working only within list properties and VBA - and by "create" I mean cut & paste code into my project; I did not write anything from scratch. In any case, it worked beautifully. I know, thanks to your website, that by using the Value in the list properties of the primary CC, a dependent text box can be auto-filled. So perhaps to clarify my question: is there a way to do all of this by only using vba and the list properties within the primary CC? I've attached the document and code here to show how far I've gotten. Is there a way to add into the existing code I have so that the text box auto-populates? |
#4
|
|||
|
|||
Given that document, this is all the code you should need.
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean) Application.ScreenUpdating = False Dim i As Long, StrOut As String With CCtrl If .Title = "Job" Then Select Case .Range.Text Case "ABC01" StrOut = "Joe Smith,Cindy Lou" ActiveDocument.SelectContentControlsByTitle("Reference").Item(1).Range.Text = CCtrl.DropdownListEntries(2).Value Case "XYZ02" StrOut = "John Doe,Jenny Lee" ActiveDocument.SelectContentControlsByTitle("Reference").Item(1).Range.Text = CCtrl.DropdownListEntries(3).Value Case "GEF03" StrOut = "Jack Handy,Jill Foote" ActiveDocument.SelectContentControlsByTitle("Reference").Item(1).Range.Text = CCtrl.DropdownListEntries(4).Value Case Else ActiveDocument.SelectContentControlsByTitle("Reference").Item(1).Range.Text = vbNullString End Select With ActiveDocument.SelectContentControlsByTitle("CM")(1) .DropdownListEntries.Clear For i = 0 To UBound(Split(StrOut, ",")) .DropdownListEntries.Add Split(StrOut, ",")(i) Next .Type = wdContentControlText .Range.Text = "" .Type = wdContentControlDropdownList End With End If End With Application.ScreenUpdating = True End Sub |
#5
|
|||
|
|||
I dug deeper and found a solution, but I'm pretty sure I went around the world and back. The way you've proposed is much simpler and much appreciated! And thanks so much for the quick replies!!
|
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Link text field to dropdown list | borus | Word | 3 | 08-16-2023 05:36 AM |
Content Controls - Dependent Dropdown | someazguy | Word VBA | 14 | 02-05-2023 08:01 PM |
Content Controls - Dependent Dropdown & Text | Mightymegs | Word VBA | 6 | 05-18-2020 05:34 AM |
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 |