View Single Post
 
Old 07-30-2018, 01:45 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
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

Youi cannot format a content control dropdown list in this manner.
You could use a selection to format text in the document, or perhaps simpler use it to insert an appropriate formatted autotext entry in a bookmarked location e.g.


Code:
Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean)
Dim orng As Range
    Select Case ContentControl.Range.Text
        Case "High"
            AutoTextToBM "bmRating", ActiveDocument.AttachedTemplate, "High"
        Case "Significant"
            AutoTextToBM "bmRating", ActiveDocument.AttachedTemplate, "Significant"
        Case "Low"
            AutoTextToBM "bmRating", ActiveDocument.AttachedTemplate, "Low"
        Case Else
            Set orng = ActiveDocument.Bookmarks("bmRating").Range
            orng.Text = ""
            ActiveDocument.Bookmarks.Add ("bmRating"), orng
    End Select
lbl_Exit:
    Set orng = Nothing
    Exit Sub
End Sub

Private Sub AutoTextToBM(strbmName As String, oTemplate As Template, strAutotext As String)
'strBMName is the name of the bookmark to fill
'oTemplate is the template with the autotext - probably ActiveDocument.AttachedTemplate
'strAutotext is the name of the autotext entry
Dim orng As Range
    On Error GoTo lbl_Exit
    With ActiveDocument
        Set orng = .Bookmarks(strbmName).Range
        Set orng = oTemplate.AutoTextEntries(strAutotext).Insert _
                   (Where:=orng, RichText:=True)
        .Bookmarks.Add Name:=strbmName, Range:=orng
    End With
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