title: Code to make selection of text and delete it
body: <p>I'm trying to create a macro to look for to specific expressions and remove that content.
  For example I need to remove everything that goes from the word "NOTIFICATION" to the expression "Good Morning" (but keeping "Good Morning, if possible).</p>
  
  <p>I have a code to remove one line, but cannot figure out how to do it with a selection, because I don't have the same number of lines every time. Could be 3 or up to 9, more or less.</p>
  
  <p>The code I have is like this (I've removed the parts of the code that did other things that are not related to this problem I have):</p>
  
  <pre><code>    Private Sub ProcessMsg(msg As MailItem)
      On Error GoTo ErrorHandlerProcessMsg
  
      Dim msg2 As Outlook.MailItem
      Dim msgDoc As Word.Document
      Dim msgDoc2 As Word.Document
      Dim objSel As Word.Selection
  
      Set msg2 = Application.CreateItem(olMailItem)
      Set msgDoc = msg.GetInspector.WordEditor
      Set msgDoc2 = msg2.GetInspector.WordEditor
  
      msgDoc.Select
      msgDoc.Windows(1).Selection.Copy
      msgDoc2.Windows(1).Selection.PasteAndFormat wdPasteDefault
  
      Set objSel = msgDoc2.Windows(1).Selection
      With objSel
          .Find.Execute "NOTIFICATION"
          .Collapse wdCollapseStart
          .MoveEnd WdUnits.wdStory, 1
          .Delete
      End With
  
      Set objSel = msgDoc2.Windows(1).Selection
      With objSel
          .MoveStart WdUnits.wdStory, -1
          .Collapse wdCollapseStart
          .MoveEnd WdUnits.wdParagraph, 1
          .Delete
      End With
  
  
      Set msgDoc = Nothing
      Set msgDoc2 = Nothing
      Set objSel = Nothing
      Set msg2 = Nothing
  
      Exit Sub
  ErrorHandlerProcessMsg:
      Set msgDoc = Nothing
      Set msgDoc2 = Nothing
      Set objSel = Nothing
      Set msg2 = Nothing
      Err.Raise Err.Number, Err.Source, Err.Description
  End Sub
  </code></pre>
  
  <p>Could anyone enlighten me?</p>