![]() |
|
#1
|
||||
|
||||
![]()
For:
Dependent Text Content Controls 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 Dependent Dropdown Content Controls https://www.msofficeforums.com/word-...html#post77762 and, for multiple levels of dependency: https://www.msofficeforums.com/word-...tml#post132696 Cascading Dropdown Content Controls https://www.msofficeforums.com/word-...html#post94603
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#2
|
|||
|
|||
![]() Quote:
I've gone thru those. But not as what I expect. I want to have the coding as follow. But this for single dd content control. But the code I am looking for Multiple dd content control. How does that work? Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) Dim oCC As ContentControl For Each oCC In ActiveDocument.ContentControls If oCC.Title = "Room" Then Select Case oCC.Range.Text Case "Room 1" ActiveDocument.SelectContentControlsByTitle("Seats ").Item(1).Range.Text = "63 Seats" Case "Room 2" ActiveDocument.SelectContentControlsByTitle("Seats ").Item(1).Range.Text = "25 Seats" Case "Room 3" ActiveDocument.SelectContentControlsByTitle("Seats ").Item(1).Range.Text = "42 Seats" Case Else ActiveDocument.SelectContentControlsByTitle("Seats ").Item(1).Range.Text = ActiveDocument.SelectContentControlsByTitle("Seats ").Item(1).PlaceholderText End Select End If Next oCC lbl_Exit: Set oCC = Nothing Exit Sub End Sub Last edited by philip.anthony; 03-25-2022 at 12:02 PM. |
#3
|
||||
|
||||
![]() Quote:
• map those content controls; or • use VBA code to loop through your "Seats " collection. For example, using the approach in that link: Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) Dim i As Long, Seats As String With ContentControl If .Title = "Room" Then For i = 1 To .DropdownListEntries.Count If .DropdownListEntries(i).Text = .Range.Text Then Seats = .DropdownListEntries(i).Value Exit For End If Next With ActiveDocument.SelectContentControlsByTag("Seats ") For i = 1 To .Count .Item(i).Range.Text = Seats Next End With End If End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#4
|
|||
|
|||
![]()
Hi Paul,
This approach is good. But, it limits to 255 char. I want to display more than 255 chars. However, I am able to do that. What I need is base on the value of 2nd Drop down & 4th Dropdown, I it to be display in the text box. I need each selection for Level 3 and value select from level 1, and display text in the text box eg. Case "Microsoft Windows" ' I need a validation and Display text differently according to the Brand ' For Each CCtrl In ActiveDocument.ContentControls ' If CCtrl.Tag = "Brand" Then ' Select Case CCtrl.Range.Text ' Case "IBM" ' StrDetails = "IBM Windows" ' Case "DELL" ' StrDetails = "DELL Window" ' Case "HP" ' StrDetails = "HP Windows" ' End Select I've Attached my Work also. Please review and guide me if the coding is ok. |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
silverspr | Word VBA | 9 | 09-30-2020 07:53 AM |
![]() |
matthias92701 | Word VBA | 2 | 05-02-2019 03:54 PM |
Content Control DropDown List | gabster | Word VBA | 4 | 04-30-2019 09:53 PM |
![]() |
hrzagi | Word | 1 | 12-17-2017 09:38 PM |
![]() |
asteinroeder | Word VBA | 5 | 10-28-2015 03:56 PM |