View Single Post
 
Old 04-04-2019, 06:28 AM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Gordon,


It just takes practice (lots of it).

If you are talking about many CCs (rather than just five), you can simplify that code greatly:



Code:
Private Sub Document_ContentControlOnExit(ByVal CC As ContentControl, Cancel As Boolean)
  With CC
    Select Case .Title
      Case "condition", "location", "sewerage", "services", "comms"
        FillFrenchCC CC
    End Select
  End With
End Sub

Sub FillFrenchCC(oCC As ContentControl)
Dim lngIndex As Long
  With oCC
    For lngIndex = 1 To .DropdownListEntries.Count
      If .DropdownListEntries(lngIndex).Text = .Range.Text Then
        ActiveDocument.SelectContentControlsByTitle(oCC.Title & "FR").Item(1).Range.Text = .DropdownListEntries(lngIndex).Value
        Exit For
      End If
    Next lngIndex
  End With
End Sub

Hint: If all CCs in the document are paired with a French couterpart then the code could be simplified even further.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote