Trouble to remove background color

G

Guillermo

I want to remove the background color of a range. This must be easy, but I can't get
it working...

<code>

Sub DeleteCorrectionMarks()

Dim TodoElTexto As Range

Set TodoElTexto = ActiveDocument.Range

With TodoElTexto.Find
.ClearFormatting
.MatchWildcards = True
.Format = True
.Font.Underline = wdUnderlineWavy
.Font.UnderlineColor = wdColorRed

With .Replacement
.Text = "^&"
.Font.Underline = wdUnderlineNone
.Font.Shading.BackgroundPatternColor = 'which constant here?


End With

.Execute Replace:=wdReplaceAll
End With
End Sub

</code>

The macro I run before this one formats my text this way:
Code:

<code>

.Font.Shading.BackgroundPatternColor = wdColorYellow

....

With .Font
.Underline = wdUnderlineWavy
.UnderlineColor = wdColorRed
End With

</code>

If I wanted to remove the shading manually, I'd have to pick "No Fill" in the
corresponding Word's dialog box, but I can't figure out a way to do that via VBA. If I
run my macro, only the underline formatting dissappears.

Cheers,

Guillermo
 
H

Helmut Weber

Hi Guillermo,

wdauto seems to do the trick,
as well as wdcolorautomatic,
unless the shading has been defined in a style.

The you may have to set the color to wdcolorwhite.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top