View Single Post
 
Old 02-11-2021, 07:19 AM
gmaxey gmaxey is offline Windows 10 Office 2016
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
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