
09-09-2020, 06:57 AM
|
Novice
|
|
Join Date: Jan 2020
Posts: 5
|
|
Quote:
Originally Posted by gmayor
Hmmm. The following will do what you ask, however if you delete the text block this will affect the second part because of text flow:
Code:
Sub Macro1()
Dim oRng As Range
Dim sText1 As String, sText2 As String
sText1 = "service on the seller"
sText2 = "service on the Buyer"
Set oRng = ActiveDocument.Range
If InStr(1, oRng, sText1) = 0 Then
MsgBox sText1 & " not found"
GoTo lbl_Exit
End If
If InStr(1, oRng, sText2) = 0 Then
MsgBox sText2 & " not found"
GoTo lbl_Exit
End If
With oRng
.Start = .Start + InStr(oRng, sText1) - 1
.End = .Start + InStr(oRng, sText2) + Len(sText2)
.Text = ""
End With
lbl_Exit:
Set oRng = Nothing
Exit Sub
End Sub
Sub Macro2()
Dim oRng As Range
Dim sText1 As String
sText1 = "removal Slip"
Set oRng = ActiveDocument.Range
If InStr(oRng, sText1) > 0 Then
With oRng
.Start = .Start + InStr(oRng, sText1) - 1
.Collapse 1
.Select
End With
ActiveDocument.Bookmarks("\page").Range.Delete
Else
MsgBox sText1 & " not found"
End If
lbl_Exit:
Set oRng = Nothing
Exit Sub
End Sub
|
Thank you very much for this real quick solution. This is where the forum and the legends help the novice like us...!
|