Quote:
Originally Posted by gmayor
The following will do what you ask:
Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim strDetails As String
Dim oCC As ContentControl
Dim oRng As Range
Set oCC = ActiveDocument.SelectContentControlsByTitle("Grade").Item(1)
Select Case oCC.Range.Text
Case "LOW"
strDetails = "7.1.5 Umbrella Insurance with a minimum limit of not less than $2,000,000 per" & vbCr & _
" occurrence."
Case "MINIMAL"
strDetails = " "
End Select
If ActiveDocument.Bookmarks.Exists("BM7") Then
Set oRng = ActiveDocument.Bookmarks("BM7").Range
oRng.Text = strDetails
oRng.Bookmarks.Add "BM7"
Set oRng = ActiveDocument.Bookmarks("BM7").Range
With oRng.Find
Do While .Execute("Umbrella Insurance")
oRng.Font.Underline = wdUnderlineSingle
Exit Do
Loop
End With
Set oRng = ActiveDocument.Bookmarks("BM7").Range
With oRng.Find
Do While .Execute("2,000,000")
oRng.Font.Bold = True
Exit Do
Loop
End With
Set oRng = ActiveDocument.Bookmarks("BM7").Range
With oRng.Find
Do While .Execute("7.1.5")
oRng.Font.Bold = True
Exit Do
Loop
End With
End If
lbl_Exit:
Exit Sub
End Sub
|
I tried the code and it works, but when I change the drop down menu from Low to Minimal and back to Low, the text is all bold and distorted.
Could this be an issue with formatting within the Word document since its pasting the text, removing it and adding it back?
Thanks!