Creating a macro to replace text

J

João Correia

Hi,
I'm trying to create a macro that deletes all the text
with the red color. To do that I make a find & replace,
but I keep the "find what" field blank, just changing
the "font color" to red (format > font color).
The "Replace with" field remains blank either, because I
want the text to disappear. When I'm recording the macro,
it works fine, but when I try to use it, nothing happens.
I took a look at the macro's code and there is no
information about the "format".

I'd like to know if I'm doing something wrong or if
there's any other way to do this.

Thanks,

João Correia
 
D

Dave Lett

Hi João,

You can use something like the following:

With Selection
.HomeKey Unit:=wdStory
With .Find
.ClearFormatting
.Text = ""
.Font.Color = wdColorRed
With .Replacement
.ClearFormatting
.Text = ""
End With
.Execute Replace:=wdReplaceAll
End With
End With

HTH,
Dave

Hi,
I'm trying to create a macro that deletes all the text
with the red color. To do that I make a find & replace,
but I keep the "find what" field blank, just changing
the "font color" to red (format > font color).
The "Replace with" field remains blank either, because I
want the text to disappear. When I'm recording the macro,
it works fine, but when I try to use it, nothing happens.
I took a look at the macro's code and there is no
information about the "format".

I'd like to know if I'm doing something wrong or if
there's any other way to do this.

Thanks,

João Correia
 

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