Consulting

Results 1 to 2 of 2

Thread: Macro to Delete All Paragraphs Beginning With the Word "Commit"

  1. #1

    Macro to Delete All Paragraphs Beginning With the Word "Commit"

    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

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    You don't need a macro for that - it can all be done via a wildcard Find/Replace, where:
    Find = ^13Commit*^13
    Replace = ^p
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •