Hi again Macropod and others,
Thanks for all the feedback. I managed to get things working. I do need help with something else.
Basically, I have parent content control "Spouse" and "A&A" as child.
if spouse is Yes, then A&A has multiple selection options, but of the different options, IF either "spouse is able and available" or "spouse is able and partially available" then I need that value outputted somewhere in the document. Currently, I'm doing that in the form of dropdown. I would prefer a neater solution... preferable as text output when one of those 2 is selected in A&A. Would appreciate if you can reply with the code needed for this. Please post complete code so that I can copy/paste and replace the entire thing.
below is existing code in it's entirety:
Code:
Option Explicit
Dim StrOption As String
Private Sub Document_ContentControlOnEnter(ByVal CCtrl As ContentControl)
With CCtrl
Select Case .Title
Case "Spouse", "A&A", "Minor": StrOption = .Range.Text
End Select
End With
End Sub
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
Application.ScreenUpdating = False
Dim i As Long, StrOut As String
With CCtrl
' /// SPOUSE - ABLE & AVAILABLE
If .Title = "Spouse" Then
If StrOption = .Range.Text Then Exit Sub
Select Case .Range.Text
Case "Yes"
StrOut = "Spouse is able and available,Spouse is able and partially available,Spouse is able but not available,Spouse is available but not able,Spouse is IHSS Recipient,Other"
Case "No"
StrOut = "N/A"
Case "Recipient is not married"
StrOut = "N/A"
Case Else
.Type = wdContentControlText
.Appearance = wdContentControlTags
.Range.Text = ""
.Type = wdContentControlDropdownList
.Appearance = wdContentControlTags
End Select
With ActiveDocument.SelectContentControlsByTitle("A&A")(1)
.DropdownListEntries.Clear
For i = 0 To UBound(Split(StrOut, ","))
.DropdownListEntries.Add Split(StrOut, ",")(i)
Next
.Type = wdContentControlText
.Appearance = wdContentControlTags
.Range.Text = ""
.Type = wdContentControlDropdownList
.Appearance = wdContentControlTags
End With
End If
' /// SPOUSE - ALTERNATE RESOURCE
If .Title = "A&A" Then
If StrOption = .Range.Text Then Exit Sub
Select Case .Range.Text
Case "Spouse is able and available"
StrOut = "Spouse is able and available."
Case "Spouse is able and partially available"
StrOut = "Spouse is able and partially available."
Case Else
.Type = wdContentControlText
.Appearance = wdContentControlTags
.Range.Text = ""
.Type = wdContentControlDropdownList
.Appearance = wdContentControlTags
End Select
With ActiveDocument.SelectContentControlsByTitle("AltResource-Spouse")(1)
.DropdownListEntries.Clear
For i = 0 To UBound(Split(StrOut, ","))
.DropdownListEntries.Add Split(StrOut, ",")(i)
Next
.Type = wdContentControlText
.Appearance = wdContentControlTags
.Range.Text = ""
.Type = wdContentControlDropdownList
.Appearance = wdContentControlTags
End With
End If
' /// MINOR
If .Title = "Minor" Then
If StrOption = .Range.Text Then Exit Sub
Select Case .Range.Text
Case "Yes", "Recipient is not a minor"
StrOut = "N/A"
Case "Recipient is not a minor"
StrOut = "N/A"
Case "No"
StrOut = "Parent is prevented from full-time employment due to child's needs,Recipient is under the care of a Legal Guardian"
Case Else
.Type = wdContentControlText
.Range.Text = ""
.Type = wdContentControlDropdownList
End Select
With ActiveDocument.SelectContentControlsByTitle("MinorExp")(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