View Single Post
 
Old 04-03-2019, 11:28 AM
Haygordon Haygordon is offline Windows 10 Office 2013
Novice
 
Join Date: Sep 2018
Posts: 5
Haygordon is on a distinguished road
Unhappy Problems adding options

Thanks for the code advice - it works well on the first drop down box but comes up with errors when I add the remaining 4 options.
errors appearing are : End Select without End Case
Select Case without End Select


It seems to be going in circles.
Help!!!


Gordon


The amended code is shown below:
Quote:
Option Explicit
Private Sub Document_ContentControlOnExit(ByVal CC As ContentControl, Cancel As Boolean)
Dim lngIndex As Long
With CC
Select Case .Title
Case "condition"
For lngIndex = 1 To .DropdownListEntries.Count
If .DropdownListEntries(lngIndex).Text = .Range.Text Then
ActiveDocument.SelectContentControlsByTitle("condi tionFR").Item(1).Range.Text = .DropdownListEntries(lngIndex).Value
Exit For
End If
Next lngIndex
With CC
Select Case .Title
Case "location"
For lngIndex = 1 To .DropdownListEntries.Count
If .DropdownListEntries(lngIndex).Text = .Range.Text Then
ActiveDocument.SelectContentControlsByTitle("locat ionFR").Item(1).Range.Text = .DropdownListEntries(lngIndex).Value
Exit For
End If
Next lngIndex
With CC
Select Case .Title
Case "sewerage"
For lngIndex = 1 To .DropdownListEntries.Count
If .DropdownListEntries(lngIndex).Text = .Range.Text Then
ActiveDocument.SelectContentControlsByTitle("sewer ageFR").Item(1).Range.Text = .DropdownListEntries(lngIndex).Value
Exit For
End If
Next lngIndex
With CC
Select Case .Title
Case "services"
For lngIndex = 1 To .DropdownListEntries.Count
If .DropdownListEntries(lngIndex).Text = .Range.Text Then
ActiveDocument.SelectContentControlsByTitle("servi cesFR").Item(1).Range.Text = .DropdownListEntries(lngIndex).Value
Exit For
End If
Next lngIndex
With CC
Select Case .Title
Case "comms"
For lngIndex = 1 To .DropdownListEntries.Count
If .DropdownListEntries(lngIndex).Text = .Range.Text Then
ActiveDocument.SelectContentControlsByTitle("comms FR").Item(1).Range.Text = .DropdownListEntries(lngIndex).Value

End Select
Exit For
End If
Next lngIndex
End Sub
Reply With Quote