R
RRodrigues
Hi,
I've a problem with a code, to find some words between bookmarks and copy
the whole line to another document.
Here’s my code:
Dim rngBkm As Range
Set rngBkm = ActiveDocument.Range( _
Start:=ActiveDocument.Bookmarks("PrejSt").Start, _
End:=ActiveDocument.Bookmarks("PrejEnd").Range.End)
rngBkm.Select
With rngBkm.Find
.ClearFormatting
Do While rngBkm.Find.Execute(FindText:="Word", Format:=True, Forward:=True)
If .Found = True Then
With .Parent
.Select
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
Windows("Document3").Activate
Selection.PasteAndFormat (wdPasteDefault)
Windows("Relcomp.doc").Activate
Selection.MoveRight Unit:=wdCharacter, Count:=1
End With
Else
Exit Do
End If
Loop
End With
However, the code doesn’t stop to find at the end of the range, but only in
the end of the document.
Can you help me with this?
I've a problem with a code, to find some words between bookmarks and copy
the whole line to another document.
Here’s my code:
Dim rngBkm As Range
Set rngBkm = ActiveDocument.Range( _
Start:=ActiveDocument.Bookmarks("PrejSt").Start, _
End:=ActiveDocument.Bookmarks("PrejEnd").Range.End)
rngBkm.Select
With rngBkm.Find
.ClearFormatting
Do While rngBkm.Find.Execute(FindText:="Word", Format:=True, Forward:=True)
If .Found = True Then
With .Parent
.Select
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Copy
Windows("Document3").Activate
Selection.PasteAndFormat (wdPasteDefault)
Windows("Relcomp.doc").Activate
Selection.MoveRight Unit:=wdCharacter, Count:=1
End With
Else
Exit Do
End If
Loop
End With
However, the code doesn’t stop to find at the end of the range, but only in
the end of the document.
Can you help me with this?