View Single Post
 
Old 03-03-2013, 06:43 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

Yes it was a typo. Paul's code applied the character style to the existing text of the control. To apply it to the control itself, you need to extended the start and end range by 1:

Code:
Sub Demo()
Dim oRng As Word.Range
Dim oStyle As Style, oControl As ContentControl
Set oStyle = ActiveDocument.Styles.Add("RTCCStyle", wdStyleTypeCharacter)
With oStyle
    .QuickStyle = True
    .Font.Underline = wdUnderlineThick
    .Font.UnderlineColor = wdColorBlack
    .Font.Italic = True
    .Font.ColorIndex = wdRed
End With
For Each oControl In ActiveDocument.ContentControls
  If oControl.Type = wdContentControlRichText Then
    Set oRng = oControl.Range
    oRng.Start = oRng.Start - 1
    oRng.End = oRng.End + 1
    oRng.Style = oStyle.NameLocal
  End If
Next oControl
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote