View Single Post
 
Old 02-20-2023, 10:05 PM
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

If you use a ListBox content control titled 'Size' then the following macro in the ThisDocument module of the document/template will populate the two text controls with the values shown, when you click out of the list box.
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim oCC As ContentControl
    If ContentControl.Title = "Size" Then
        If ContentControl.ShowingPlaceholderText = False Then
            Select Case ContentControl.Range.Text
                Case "Large"
                    Set oCC = ActiveDocument.SelectContentControlsByTitle("Height").Item(1)
                    oCC.Range.Text = "123 cm"
                    Set oCC = ActiveDocument.SelectContentControlsByTitle("Width").Item(1)
                    oCC.Range.Text = "234 cm"
                Case "Small"
                    Set oCC = ActiveDocument.SelectContentControlsByTitle("Height").Item(1)
                    oCC.Range.Text = "25 cm"
                    Set oCC = ActiveDocument.SelectContentControlsByTitle("Width").Item(1)
                    oCC.Range.Text = "36 cm"
            End Select
        Else
            Set oCC = ActiveDocument.SelectContentControlsByTitle("Height").Item(1)
            oCC.Range.Text = ""
            Set oCC = ActiveDocument.SelectContentControlsByTitle("Width").Item(1)
            oCC.Range.Text = ""
        End If
    End If
    Set oCC = Nothing
End Sub
Had there been more than two values to consider, you could have added values to the list box and split the values to provide the results.
You may find Insert Content Control Add-In useful.
__________________
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