Referencing the current VISIBLE page

A

automandc

I am wondering if there is a way for my routine to identify what portion of
an active document is currently visible in the window, regardless of where
the insertion point is?

E.g. if I have a window that says "Document one.doc is currently open to
page __" and I want the blank filled in with the page number that is
displayed in the window, even if the insertion point is elsewhere, how would
I do that?

I think this may be a backwards example of "ScrollInto" method, but I have
not found any properties that link the Window object with the visible portion
of the document, only with the current insertion point or predefined range.

Thanks
 
M

Martin Seelhofer

Hi there

Maybe something like the following will get you started:

Dim w As Long
Dim h As Long
Dim rng As Range
w = ActiveWindow.Width
h = ActiveWindow.Height

Set rng = ActiveWindow.RangeFromPoint(w / 2, h)
MsgBox rng.Information(wdActiveEndPageNumber)


Not too exact but useable :)


Cheers,
Martin
 
A

automandc

Thanks for the response. Sorry to be dense, but I am comparing your example
to the standard help for the RangeFromPoint method, and it seems that this
will only work if there is a range already defined in that place? Am I
missing something? Also, why do you divide the width by 2 in your example?

The word application window keeps track of the visible page in the status
bar, so it seems like the application is somewhere associating the visible
portion of the document. Is there a way to access that information directly?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top