Advanced search and replace.

P

Piotr

Hi,
i have a document looking like that:
"this is a line with a word cat
this is a line with a word dog
this is a line with a word dog
this is a line with a word cat
this is a line with a word cat
this is a line with a word dog
this is a line with a word cat"
What i have to do is to delete all the lines containing the word "cat". If
it was only few lines i could just do it manually searching and deleting, but
this document has more than 100 pages, and the lines are not one after
another but they are among other sequences.
Is there any way to automate such process? I thought about using replace
function, but i don't think it's capable.
With regards, Peter
 
D

Doug Robbins - Word MVP

Use a macro containing the following code:

Dim myrange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="cat", Forward:=True, _
MatchWildcards:=False, Wrap:=wdFindStop, MatchCase:=False) = True
Selection.Paragraphs(1).Range.Delete
Loop
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

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