Start Find not whole document

  • Thread starter FIRSTROUNDKO via OfficeKB.com
  • Start date
F

FIRSTROUNDKO via OfficeKB.com

Hi!

From the code below, please can somebosy tell me how to start the "find" for
ph1 and ph2 from page 4.


Sub abcxyz()

Dim pH1 As Word.Range
Dim pH2 As Word.Range
Dim pTarget As Word.Range
Dim Doc1 As Word.Document
Dim Doc2 As Word.Document

Set Doc1 = ActiveDocument ' at the time the macro starts
'Set Doc2 = wrdApp.Documents.Add(DocumentType:=wdNewBlankDocument)


Set pH1 = Doc1.Range

With pH1.Find
.ClearFormatting
.Text = "abc"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = False
.Execute
End With

Set pH2 = Doc1.Range

With pH2.Find
.ClearFormatting
.Text = "xyz"
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchWildcards = False
.Execute
End With

Set pTarget = Doc1.Range(Start:=pH1.End + 1, End:=pH2.Start - 1)
Word.Documents.Add
pTarget.Copy
ActiveDocument.Range.Paste

End Sub

Thanks In Advance
 
Top