View Single Post
 
Old 09-24-2021, 04:30 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The following will do what you require. The second macro is superfluous.The macro assumes that the value associated with the list item is not the same as the list item e.g.


Choose an item.
RED|Value 1
AMBER|Value 2
GREEN|Value 3


Thus if you select RED, 'Value 1' is displayed.


You can edit the list easily with
https://www.gmayor.com/insert_content_control_addin.htm
Code:
Private Sub Document_ContentControlOnExit(ByVal CC As ContentControl, Cancel As Boolean)
Dim lngIndex As Long
Dim strValue As String
    Select Case CC.Title
        Case "RAG"
            With CC
                If .ShowingPlaceholderText Then Exit Sub
                Select Case .Range.Text
                    Case "RED": .Range.Font.Color = RGB(178, 34, 34)
                    Case "AMBER": .Range.Font.Color = RGB(255, 165, 0)
                    Case "GREEN": .Range.Font.Color = RGB(50, 205, 50)
                    Case Else: .Range.Font.ColorIndex = wdAuto
                End Select
                For lngIndex = 2 To .DropdownListEntries.Count
                    If .DropdownListEntries(lngIndex).Text = .Range.Text Then
                        strValue = .DropdownListEntries(lngIndex).Value
                        .Type = wdContentControlText
                        .Range.Text = strValue
                        .Type = wdContentControlDropdownList
                        Exit For
                    End If
                Next lngIndex
            End With
        Case Else
    End Select
lbl_Exit:
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote