Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-31-2018, 03:58 PM
jjfreedman jjfreedman is offline VBA change font color to background color Windows 10 VBA change font color to background color 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
Reply

Tags
background color, font color



Similar Threads
Thread Thread Starter Forum Replies Last Post
Change excel background color, strange... sojiro Excel 7 04-18-2018 10:07 AM
Style Font Color: Background 1 gmgj Word 3 12-20-2017 04:00 PM
Advanced Font Color Manipulation In Word: Inserting another color than the surrounding text stuartg Word 1 02-20-2017 12:38 AM
VBA change font color to background color Remove white text background (keeping the font color and page color intact cc3125 Word 1 10-26-2015 06:44 PM
Font Color Question//.Replacement.Font.Color = 12611584 rsrasc Word VBA 3 09-05-2015 09:03 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:44 PM.


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