Macro to look for highlighted text and delete it

E

excelnut1954

I want the macro to look through the document for any text that is
highlighted (it will be in yellow), and delete the text, and remove the
highlight.

I'd appreciate any help.
Thanks,
J.O.
 
G

Greg Maxey

Try:

Sub ScratchMacro()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Highlight = True
While .Execute
oRng.Delete
Wend
End With
End Sub
 
H

Helmut Weber

Hi J.O.,

maybe this is sufficient:

Sub Test445()
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Highlight = True
.Replacement.Text = ""
.Execute Replace:=wdReplaceAll
End With
End Sub

HTH


--
Gruß

Helmut Weber, MVP WordVBA

"red.sys" & chr$(64) & "t-online.de"
Win XP, Office 2003 (US-Versions)
 
E

excelnut1954

I've been away from all this.... so, thanks to both of you for your
solutions. I'll try them today.
Thanks again
J.O.
 

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