I have defined a range. Now I need to be able to search for a specific
phrase, move to the end of that phrase, insert a carriage return and insert a
new phrase. This is what I was trying, but it is not working. I don't get
any errors. It just doesn't work. I'm pretty sure it has something to do
with meNotice vs. selection. But I just can't quite figure out the syntax.
Any help would be greatly appreciated.

Set meNotice = .Sections(.Sections.Count).Range

With meNotice.Find
.Text = "time shown below."
If .Execute Then

Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.InsertAfter Chr$(13) & "PLEASE TELEPHONE ME IMMEDIATELY."

End If
End With

RE: Search within a range by SHewes

SHewes
Tue Apr 08 08:37:01 PDT 2008

Try this

Set meNotice = ActiveDocument.Sections(ActiveDocument.Sections.Count).Range

meNotice.Select
Selection.Find.Text = "time shown below."
If Selection.Find.Execute Then
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.InsertAfter Chr$(13) & "PLEASE TELEPHONE ME IMMEDIATELY."
End If


-------------------
S. Hewes


"Elaine J." wrote:

> I have defined a range. Now I need to be able to search for a specific
> phrase, move to the end of that phrase, insert a carriage return and insert a
> new phrase. This is what I was trying, but it is not working. I don't get
> any errors. It just doesn't work. I'm pretty sure it has something to do
> with meNotice vs. selection. But I just can't quite figure out the syntax.
> Any help would be greatly appreciated.
>
> Set meNotice = .Sections(.Sections.Count).Range
>
> With meNotice.Find
> .Text = "time shown below."
> If .Execute Then
>
> Selection.MoveRight Unit:=wdCharacter, Count:=2
> Selection.InsertAfter Chr$(13) & "PLEASE TELEPHONE ME IMMEDIATELY."
>
> End If
> End With