How can I colour anything within a bracket using an IF Statement

M

mrlylos

Hi all,

I've got a document that is a mixture of plain text in between brackets, for
example:

<p>I need to be translated</p>
<p>please translate me</p>

The document is large and has many instances of tags and plain text and what
I want to do is be able to write an IF statement that colours anything within
the <> brackets red.

Cany anyone help?

Many thanks in advance

mrlylos
 
P

Pesach Shelnitz

Hi,

The following macro does this.

Sub ColorThemRed()
Dim myRange As Range
Set myRange = ActiveDocument.Range

With myRange
.start = 0
Do While .Find.Execute(FindText:="\<*\</*\>", _
MatchWildcards:=True, _
Wrap:=wdFindStop, Forward:=True) = True
.Font.Color = wdColorRed
.Collapse Direction:=wdCollapseEnd
Loop
End With
Set myRange = Nothing
End Sub
 

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