Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Piotr Piotr is offline
external usenet poster
 
Posts: 2
Default Advanced search and replace.

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
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Doug Robbins - Word MVP Doug Robbins - Word MVP is offline
external usenet poster
 
Posts: 8,832
Default Advanced search and replace.

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

"Piotr" wrote in message
...
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


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search and Insert, Search and Replace, Modify Document Margins instant000 Formatting Long Documents 2 October 26th 09 09:34 PM
advanced replace Good Ghost Microsoft Word Help 5 June 8th 07 01:30 PM
Advanced File Search on most Properties doesn't seem to work Clive Elsworth Microsoft Word Help 1 September 5th 05 01:45 PM
How advanced is the "replace" function in Word 2000? Ted Shoemaker Microsoft Word Help 6 July 9th 05 02:17 PM
How advanced is the "replace" function in Word 2000? Ted Shoemaker New Users 6 July 9th 05 02:17 PM


All times are GMT +1. The time now is 06:34 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"