Well, I've tried a variation on the theme you suggested. Now, the problem is
that it seems to continue looping even after 'wend' is hit. I tried including
a "stop" command but either the system doesn't recognise it or just doesn't
care ( * snif * ).
Just so you know, I'm trying to pull about 200 lines (got the number from a
find-all search) out of a 16,000 page document.
Here's what I've got so far...
Sub FindLine2Copy()
'
' FindLine2Copy Macro
' Macro recorded 07/26/2007 by Doc Farmer
'
Selection.Find.ClearFormatting
With Selection.Find
.Text = "xyz"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
Selection.EndKey Unit:=wdLine
Documents.Add DocumentType:=wdNewBlankDocument
Selection.PasteAndFormat (wdPasteDefault)
While (True)
Windows(2).Activate
Selection.Find.ClearFormatting
With Selection.Find
.Text = "xyz"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
Selection.EndKey Unit:=wdLine
Windows(1).Activate
Selection.PasteAndFormat (wdPasteDefault)
Windows(2).Activate
Selection.Find.ClearFormatting
With Selection.Find
.Text = "xyz"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
Selection.EndKey Unit:=wdLine
Windows(1).Activate
Selection.PasteAndFormat (wdPasteDefault)
Windows(2).Activate
Selection.Find.ClearFormatting
With Selection.Find
.Text = "xyz"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.HomeKey Unit:=wdLine
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
Selection.EndKey Unit:=wdLine
Windows(1).Activate
Selection.PasteAndFormat (wdPasteDefault)
Wend
Windows(1).Activate
Stop
End Sub