R
RNEELY
Given a document with the following text:
The quick brown fox jumped high.
There is a cat over the lazy dog.
The quick brown fox jumped.
There is a bird over the lazy dog.
How can I write a macro to delete the text between ‘jumped’ and ‘over’ so
the document ends up like:
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The following macro finds the end of ‘jumped’:
Sub FindFoxyJump()
Selection.Find.ClearFormatting
With Selection.Find
.Text = "jumped"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1
End Sub
Specifically how can one begin a selection from that location, and extend it
to the beginning of ‘over’? While it is simple to select text by moving the
cursor with
Selection.MoveDown Unit:=wdLine, Count:=2, Extend:=wdExtend
There seems to be no such Extend:=wdExtend argument for
Selection.Find.Execute.
Please help. I am really stuck.
The quick brown fox jumped high.
There is a cat over the lazy dog.
The quick brown fox jumped.
There is a bird over the lazy dog.
How can I write a macro to delete the text between ‘jumped’ and ‘over’ so
the document ends up like:
The quick brown fox jumped over the lazy dog.
The quick brown fox jumped over the lazy dog.
The following macro finds the end of ‘jumped’:
Sub FindFoxyJump()
Selection.Find.ClearFormatting
With Selection.Find
.Text = "jumped"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight Unit:=wdCharacter, Count:=1
End Sub
Specifically how can one begin a selection from that location, and extend it
to the beginning of ‘over’? While it is simple to select text by moving the
cursor with
Selection.MoveDown Unit:=wdLine, Count:=2, Extend:=wdExtend
There seems to be no such Extend:=wdExtend argument for
Selection.Find.Execute.
Please help. I am really stuck.