View Single Post
 
Old 05-31-2018, 03:58 PM
jjfreedman jjfreedman is offline Windows 10 Office 2016
Advanced Beginner
 
Join Date: May 2012
Location: https://jay-freedman.info
Posts: 39
jjfreedman is on a distinguished road
Default

For manual setting of a specific paragraph, put the cursor in that paragraph and run this code:
Code:
Sub x()
    With Selection.Paragraphs(1).Range
        If .Shading.BackgroundPatternColor = wdColorAutomatic Then
            .Shading.BackgroundPatternColor = wdColorWhite
        End If
            
        .Font.TextColor.RGB = .Shading.BackgroundPatternColor
    End With
End Sub
For use in your macro that inserts the title, change "Selection.Paragraphs(1).Range" to the range of the paragraph that contains the title.

The If section is needed because setting both the font and the shading to Automatic gives black text on white background.
Reply With Quote