Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-03-2013, 12:46 AM
macropod's Avatar
macropod macropod is offline Rich Text Content Controls: Formatting? Windows 7 64bit Rich Text Content Controls: Formatting? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,536
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I'd suggest using a character Style rather than a paragraph Style, as it means you can use this Style in paragraphs that are otherwise formatted differently.



Here's how you can apply it to all Rich Text content controls:
Code:
Sub Demo()
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
    oControl.Range.Style =  = oStyle.NameLocal
  End If
Next oControl
End Sub
If you only want to apply it to some Rich Text content controls, you'll need additional rules you can test with If statements. For example, any one or more of the Section of the document, the Rich Text content control's title, a bookmarked range could be used.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]

Last edited by macropod; 03-03-2013 at 12:49 AM. Reason: Minor code enhancement
Reply With Quote
  #2  
Old 03-03-2013, 05:04 AM
tinfanide tinfanide is offline Rich Text Content Controls: Formatting? Windows 7 64bit Rich Text Content Controls: Formatting? Office 2010 32bit
Expert
Rich Text Content Controls: Formatting?
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
I'd suggest using a character Style rather than a paragraph Style, as it means you can use this Style in paragraphs that are otherwise formatted differently.
What are the differences between Character Style and Paragraph Style? I've been wondering.
Reply With Quote
  #3  
Old 03-03-2013, 05:15 AM
tinfanide tinfanide is offline Rich Text Content Controls: Formatting? Windows 7 64bit Rich Text Content Controls: Formatting? Office 2010 32bit
Expert
Rich Text Content Controls: Formatting?
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default

Code:
oControl.Range.Style = = oStyle.NameLocal
Is it a typo of the "= ="?

And,
After running the codes, I discover in the Properties of the Rich Text Controls. The "use a style to format contents" has not been checked, which means if you type anything inside the formatted Rich Text Controls, the newly typed texts won't be as formatted as expected (in this case, not turned red, still auto black).
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Rich Text Content Controls: Formatting? Rich text/Plain text Content Controls in Template michael.fisher5 Word 9 11-19-2014 06:36 AM
Rich Text Content Controls: Formatting? How do you set rich text in a content control Testor Word VBA 4 07-08-2012 07:55 AM
Rich Text Content Controls: Formatting? Rich Text Content Control - Allow User Formatting keithacochrane Word 1 05-28-2012 05:06 PM
Rich Text Content Controls: Formatting? Grouping Content Controls cksm4 Word VBA 2 03-01-2011 12:46 PM
Templates: automatic text generation from Rich Text content control Chickenmunga Word 0 10-01-2008 11:16 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:17 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2026 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft