Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-10-2021, 03:56 PM
trailrunnertcm trailrunnertcm is offline Link CC dropdown to dependent dropdown AND text box Windows 10 Link CC dropdown to dependent dropdown AND text box Office 2019
Novice
Link CC dropdown to dependent dropdown AND text box
 
Join Date: Feb 2021
Posts: 3
trailrunnertcm is on a distinguished road
Question 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.


Attached Files
File Type: docx Sample Template.docx (14.8 KB, 8 views)
Reply With Quote
  #2  
Old 02-10-2021, 04:10 PM
gmaxey gmaxey is offline Link CC dropdown to dependent dropdown AND text box Windows 10 Link CC dropdown to dependent dropdown AND text box Office 2016
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

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.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #3  
Old 02-10-2021, 05:29 PM
trailrunnertcm trailrunnertcm is offline Link CC dropdown to dependent dropdown AND text box Windows 10 Link CC dropdown to dependent dropdown AND text box Office 2019
Novice
Link CC dropdown to dependent dropdown AND text box
 
Join Date: Feb 2021
Posts: 3
trailrunnertcm is on a distinguished road
Default

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?
Attached Files
File Type: dotm Sample2 Template.dotm (28.4 KB, 16 views)
Reply With Quote
  #4  
Old 02-11-2021, 07:19 AM
gmaxey gmaxey is offline Link CC dropdown to dependent dropdown AND text box Windows 10 Link CC dropdown to dependent dropdown AND text box Office 2016
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

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 02-11-2021, 08:04 AM
trailrunnertcm trailrunnertcm is offline Link CC dropdown to dependent dropdown AND text box Windows 10 Link CC dropdown to dependent dropdown AND text box Office 2019
Novice
Link CC dropdown to dependent dropdown AND text box
 
Join Date: Feb 2021
Posts: 3
trailrunnertcm is on a distinguished road
Default

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!!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Link CC dropdown to dependent dropdown AND text box Link text field to dropdown list borus Word 3 08-16-2023 05:36 AM
Link CC dropdown to dependent dropdown AND text box Content Controls - Dependent Dropdown someazguy Word VBA 14 02-05-2023 08:01 PM
Link CC dropdown to dependent dropdown AND text box 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

Other Forums: Access Forums

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