PDA

View Full Version : [SOLVED:] Macro to Delete All Paragraphs Beginning With the Word "Commit"



docteam135
03-27-2020, 12:50 PM
Hey All,

I'm trying to create a macro that finds all paragraphs in a large document that begin with the word "Commit" and then deletes all of those paragraphs. I've seen a few different approaches for somewhat similar-ish requests, but I haven't been able to create anything that works for me.

So far, this is what I have, and I'm not sure why it's not working.

Thanks in advance!!



Sub Cleanup()


Dim oPara As Paragraph

For Each oPara In ActiveDocument.Paragraphs
With oPara.Range
If .Words(1).Text = "Commit" Then .Delete
End If
End With
Next oPara



End Sub

macropod
03-27-2020, 02:24 PM
You don't need a macro for that - it can all be done via a wildcard Find/Replace, where:
Find = ^13Commit*^13
Replace = ^p