View Single Post
 
Old 12-15-2023, 01:34 AM
RobiNew RobiNew is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Sep 2023
Posts: 183
RobiNew is on a distinguished road
Default Establish a new range after finding a string

I'm trying to establish a new range after finding a string, so that I can use Find again from the Found point to the end of the document. But the tentative code here below doesn't work. Can someone help? Thanks!
Code:
Dim oRng As Range
Set oRng = ActiveDocument.Range
    With oRng.Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Text = "Title"
      .Replacement.Text = ""
      .Forward = True
      .Wrap = wdFindContinue
      .Format = False
      .MatchCase = False
      .Execute
    End With
'Here I need to fix the starting point of a new Find, but it doesn't work
    oRng.Start = oRng.Find.Found
    oRng.End = ActiveDocument.Range.End
With oRng.Start.Find
.Text:="Section"
.Execute
End With
Reply With Quote