i want to delete all paragraphs in a document that don't have a certain word in them

R

ravi venkata

Call CheckPara("some text here")

Sub CheckPara(str As String)
Dim p As Paragraph
Dim flag As Boolean

For Each p In ActiveDocument.Paragraphs
flag = False
For i = 1 To p.Range.Words.Count
If Trim(p.Range.Words(i).Text) = str Then
flag = True
Exit For
End If
Next i
If flag = False Then
p.Range.Delete
End If
Next p
End Sub

-----Original Message-----
i want to delete all paragraphs in a document that don't
have a certain word in them. How do I do that?
 

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