Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find end of page in Word 1

Status
Not open for further replies.
Oct 5, 1999
105
GB
I'm sure it must be simple, but how do I find the end of the current page in Word.

To put it simply, I want to write a macro to copy from the current insertion point to the end of the current page. Unfortunately, I cannot guarrantee that there will be a Hard Page marker which would have been easy to find.

The current page does not seem to be an available property anywhere.

Any ideas

Thanks
Paul
 
You may play with the pre-defined bookmark "\page"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
The current page does not seem to be an available property anywhere.
That is because in Word - pre 2003 version - does not really have a page object. All pages are in fact calculated range objects. In any case, here is one possible way of doing it:
Code:
Sub ToEndOfPage()
Dim oRange As Word.Range
Selection.Collapse Direction:=wdCollapseStart
Set oRange = ActiveDocument.Range(Start:=Selection.Range.Start, _
    End:=ActiveDocument.Bookmarks("\page").Range.End)
oRange.Select
Selection.Copy
' * * * * * *  do whatever with copy * * * * *
Set oRange = Nothing
End Sub

Gerry
 
Thanks for that - I hadn't come across the \page bookmark before.

Is this in the documentation anywhere? and are there any other similar pre-defined bookmarks?

Paul
 
\Sel
\PrevSel1
\PrevSel2
\StartOfSel
\EndOfSel
\Line
\Char
\Para
\Section
\Doc
\Page
\StartOfDoc
\EndOfDoc
\Cell
\Table
\HeadingLevel

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Look up "predefined bookmarks" in Word VBA Help.

Gerry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top