![]() |
#1
|
|||
|
|||
![]()
In various stereotyped documents, I am trying
1. to delete few lines and paragraphs in between text strings "service on the seller" to "service on the Buyer" I tried this code, but it deletes all the lines after "service on the seller" till end of the document, even after removing or changing "myrange.End" Code:
Sub SelectRangeStarttext() Selection.HomeKey Unit:=wdStory Dim myrange As Range Selection.HomeKey wdStory Selection.Find.ClearFormatting With Selection.Find .Execute FindText:="service on the seller", Forward:=True, Wrap:=wdFindStop 'this will initiate the start word '"The value for the purpose of court fee and jurisdiction" Set myrange = Selection.Range myrange.End = ActiveDocument.Range.End myrange.Start = myrange.Start myrange.End = myrange.End + InStr(myrange, "service on the Buyer") ' this will initiate the end word myrange.Select Selection.Delete End With End Sub thanking you for your support |
Tags |
delete page, delete text between, from to text strings |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Extracting Specific Text Strings | PWH68 | Word VBA | 6 | 10-08-2019 02:07 AM |
Locating/deduping similar but not identical text strings | strodden | Excel | 2 | 06-25-2018 10:37 AM |
![]() |
noname91 | Word | 10 | 01-05-2017 05:46 PM |
how do I search the content of excel files for text strings | soren | Excel | 2 | 03-19-2015 09:42 AM |
![]() |
Marrick13 | Word | 2 | 04-29-2012 05:12 AM |