Paul Terwilliger
Paul Terwilliger

Reputation: 1646

Delete every row with a particular string in it

I am using Microsoft Word 2010.

I have a document spanning thousands of pages. I need to write a macro that deletes every paragraph that begins with the string mystring. How would I write this?

EDIT: I have figured out how to write a macro and how to delete a paragraph once my cursor is at the beginning of the paragraph. I need to find a way to do a "find" search

Upvotes: 1

Views: 67

Answers (1)

Nathan_Sav
Nathan_Sav

Reputation: 8531

Dim d As Document
Dim p As Paragraph

Set d = ActiveDocument

For Each p In d.Paragraphs
    If Left(p.Range, Len("Asdfsadfsdsd")) = "Asdfsadfsdsd" Then
        p.Range.Delete
    End If
Next p

Upvotes: 3

Related Questions