Move line to top of screen

R

Roger Smith

The cursor is in a line of a word document (xp) anywhere on the
screen. Need a macro to move the line to the top of the screen.

Thanks for any help.
 
W

Word Heretic

G'day (e-mail address removed) (Roger Smith),

what version of word


(e-mail address removed) (Roger Smith) was spinning this yarn:
The cursor is in a line of a word document (xp) anywhere on the
screen. Need a macro to move the line to the top of the screen.

Thanks for any help.

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

Replies offlist may require payment.
 
R

Roger Smith

Word 2002 (10.2627.2625)

Word Heretic said:
G'day (e-mail address removed) (Roger Smith),

what version of word


(e-mail address removed) (Roger Smith) was spinning this yarn:


Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

Replies offlist may require payment.
 
D

Doug Robbins - Word MVP

Hi Roger,

This is not very elegant (I don't like relying on an error), but it works:

Dim pLeft As Long
Dim pTop As Long
Dim pWidth As Long
Dim pHeight As Long
ActiveWindow.GetPoint pLeft, pTop, pWidth, pHeight, _
Selection.Range
On Error GoTo Finish
Do While pTop > 1
ActiveDocument.ActiveWindow.SmallScroll Down:=1
ActiveWindow.GetPoint pLeft, pTop, pWidth, pHeight, _
Selection.Range
Loop

Finish:
ActiveDocument.ActiveWindow.SmallScroll Up:=1

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
W

Word Heretic

G'day (e-mail address removed) (Roger Smith),

ActiveWindow.ScrollIntoView Selection.Range, True


(e-mail address removed) (Roger Smith) was spinning this yarn:
Word 2002 (10.2627.2625)

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

Replies offlist may require payment.
 
D

Doug Robbins - Word MVP

Steve,

If the cursor (selection) is in a line that is on the screen as the OP
indicated, ActiveWindow.ScrollIntoView Selection.Range, True does nothing.

If the selection is not visible, it does not move it to the top of the
screen, rather several lines from the top.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

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