In my Word document, I am trying to write VBA code to select all of the text
from the current cursor position to the previous Hard Page Break.
I don't see that there is a way to get the Find method to extend the
selection from the current location to the result of the search, but I am
sure there must be some way to do a similar thing.
Can anyone show a code example to me that would accomplish this purpose,
please.
Thank you in advance.
Dave Lett - 27 Jan 2005 19:32 GMT
Hi,
You can use something like the following:
Dim oRng As Range
Set oRng = Selection.Range
With Selection.Find
.ClearFormatting
.Text = "^m"
.Forward = False
.Execute
End With
oRng.Start = Selection.Start
oRng.Select
HTH,
Dave
> In my Word document, I am trying to write VBA code to select all of the text
> from the current cursor position to the previous Hard Page Break.
[quoted text clipped - 7 lines]
>
> Thank you in advance.
Hambster - 27 Jan 2005 19:45 GMT
Perfect. Thank you.
> Hi,
>
[quoted text clipped - 26 lines]
> >
> > Thank you in advance.
Larry - 29 Jan 2005 06:01 GMT
Just for the heck of it, here's another way to do the same thing:
Application.Run "ExtendSelection"
With Selection.Find
.ClearFormatting
.Text = "^m"
.Forward = False
.Execute
End With
'-----------------
'The ExtendSelection can then be turned off with:
' Selection.EscapeKey
> Perfect. Thank you.
>
[quoted text clipped - 30 lines]
> > >
> > > Thank you in advance.