Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / June 2005

Tip: Looking for answers? Try searching our database.

How to determine if a range starts at the top of a page?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeremy - 29 Jun 2005 00:51 GMT
This is any page, not just the first or end page. If range is not possible is
it possible with a paragraph?
Jezebel - 29 Jun 2005 01:04 GMT
You can use

MyRange.Information(wdVerticalPositionRelativeToPage)

to retrieve the vertical position of the start of range. If you know the
vertical position of a range at start of page (ie, if the layout is fixed
you can work this out in advance) then simply compare with that. Or get the
vertical position of the preceding character and compare ... if it's less,
the preceding character is on the same page, and your range is therefore not
at the start --

if activedocument.Range(MyRange.Start - 1, MyRange.Start -
1).Information(wdVerticalPositionRelativeToPage) <
MyRange.Information(wdVerticalPositionRelativeToPage) then
       ... not at start of page

Bear in mind, this will throw an error if MyRange is at the start of
document.

> This is any page, not just the first or end page. If range is not possible
> is
> it possible with a paragraph?
Jean-Guy Marcil - 29 Jun 2005 02:50 GMT
Jeremy was telling us:
Jeremy nous racontait que :

> This is any page, not just the first or end page. If range is not
> possible is it possible with a paragraph?

You could compare the currently selected selection range.start value with
the current page range.start value:

'_______________________________________
Dim curPageRge As Range
Dim curSelRge As Range

Set curSelRge = Selection.Range

curSelRge.Collapse wdCollapseStart

Set curPageRge = curSelRge.Bookmarks("\page").Range

If curSelRge.Start = curPageRge.Start Then
   MsgBox "Selection is at top of page."
Else
   MsgBox "Selection is NOT at top of page."
End If
'_______________________________________

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.