How to delete a section between two identifiable words (or phrases)

H

husbfirst

How to delete a section between two identifiable words (or phrases)? A
example is like the following, where the contents between
INVESTIGATION and EXPERIMENT (including these two word) are to be
removed:

++++
INVESTIGATION of this
topic..................................................................
..........................................................................................................
..........................................................................................................
end of the EXPERIMENT.
++++

Thanks!
 
H

Helmut Weber

like this, and in many other ways:

Public Sub DeleteRange(x As String, y As String)
' x = from, including
' y = to, including
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Text = x & "*" & y
.MatchWildcards = True
' .Matchcase ' if you like
' .MatchWholeWord ' if you like
' plus some more if required
If .Execute Then
rDcm.Text = ""
End If
End With
End Sub
' ----------------------------
Sub Test()
DeleteRange "xxxxx", "yyyyy"
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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