M
Matt Shaw
I'm trying to search a document and each time I find a target word I
want to select the whole sentence and cut and paste it into another
document; then continue to the next sentence with the target word.
I can get this to work but each time it finds the same first sentence
and won't go the "find next" point.
It's obviously something dumb I'm doing so anyone who can tell me the
error of my ways - please feed free My code looks like this --
Documents.Open Filename:="dest.doc"
Set Destination = ActiveDocument
Documents.Open Filename:="source.doc"
Set Source = ActiveDocument
target = "targetword"
With Selection.Find
.Text = target
.ClearFormatting
.MatchWholeWord = True
.MatchCase = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
Selection.StartOf Unit:=wdSentence
Selection.Expand Unit:=wdSentence
sent = Selection()
destination.Activate
selection.insertafter sent & vbCR
Source.Activate
want to select the whole sentence and cut and paste it into another
document; then continue to the next sentence with the target word.
I can get this to work but each time it finds the same first sentence
and won't go the "find next" point.
It's obviously something dumb I'm doing so anyone who can tell me the
error of my ways - please feed free My code looks like this --
Documents.Open Filename:="dest.doc"
Set Destination = ActiveDocument
Documents.Open Filename:="source.doc"
Set Source = ActiveDocument
target = "targetword"
With Selection.Find
.Text = target
.ClearFormatting
.MatchWholeWord = True
.MatchCase = False
.Wrap = wdFindStop
End With
Selection.Find.Execute
Selection.StartOf Unit:=wdSentence
Selection.Expand Unit:=wdSentence
sent = Selection()
destination.Activate
selection.insertafter sent & vbCR
Source.Activate