View Single Post
 
Old 07-31-2019, 06:29 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
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

Assuming the list box is titled 'Country' and the others are titled "Short Name" the following macro in he thisdocument module will fill the short name fields with the selection from the country as US or MEX. You may find Insert Content Control Add-In useful

Code:
Option Explicit

Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim oCC As ContentControl
    If ContentControl.ShowingPlaceholderText = False Then
        If ContentControl.Title = "Country" Then    'the title of the list box control
            Select Case Trim(ContentControl.Range.Text)
                Case "United States"
                    For Each oCC In ActiveDocument.ContentControls
                        If oCC.Title = "Short Name" Then    'the title of the fields used for the short version
                            oCC.Range.Text = "US"
                        End If
                    Next oCC
                Case "Mexico"
                    For Each oCC In ActiveDocument.ContentControls
                        If oCC.Title = "Short Name" Then
                            oCC.Range.Text = "MEX"
                        End If
                    Next oCC
                    'etc
            End Select
        End If
    End If
    Set oCC = Nothing
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