Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2005

Tip: Looking for answers? Try searching our database.

Delete a line if a word is NOT found

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Smith - 30 Jun 2005 11:18 GMT
I would like to delete a line if a keyword is not found. Can this
be done? This is to mimic what grep program does, sort of.
Helmut Weber - 30 Jun 2005 13:46 GMT
Hi John,

in case you are talking about paragraphs, not lines:

Dim oPrg As Paragraph
For Each oPrg In ActiveDocument.Paragraphs
  If InStr(oPrg.Range.Text, "und") = 0 Then
     oPrg.Range.Delete
  End If
Next

Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
John Smith - 01 Jul 2005 02:50 GMT
> Hi John,
>
[quoted text clipped - 11 lines]
> "red.sys" & chr(64) & "t-online.de"
> Word 2002, Windows 2000

Thanks. You're right. It's indeed paragraphs. Since my paragraphs
are so short, they are literally lines.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.