Reputation: 171
I wanted to know how can I change the background color of the text in Word on all my doc. For exemple I got some text with blue/red/pink background color and I want that the bg color of all my doc white.
I got and exemple for the font color :
Sub color()
'
' color Macro
'
'
Dim Plage As Object, Wrd As Object
Set Plage = ActiveDocument.Content.Words
For Each Wrd In Plage
If Wrd.Font.color = RGB(0, 0, 255) Then _
Wrd.Font.color = RGB(128, 128, 128)
Next Wrd
End Sub
But I don't know how to apply this VBA code for the background color.
Maybe with Document.Background property
?
Upvotes: 0
Views: 2436
Reputation: 29592
There are three background color settings you have to deal with:
Range.HighlightColorIndex
. To remove the highlight, use wdNoHighlight
Range.Shading.BackgroundPatternColor
. To remove it, use wdColorAutomatic
Background.Fill
of the document. Either set the ForeColor
to white, or set the visible
-property to false.To clean everything at once, use something like this:
Sub RemoveBackgroundColor()
With ActiveDocument.Content
.HighlightColorIndex = wdNoHighlight
.Shading.BackgroundPatternColor = wdColorAutomatic
End With
ActiveDocument.Background.Fill.Visible = msoFalse
End Sub
Upvotes: 6