Code to go to first character in the page

J

jeanmac

Does anyone know a piece of code that would move you to the first character
in the current page of a document? I am new to Word VBA and finding it not
the easiest, if anyone can help that would be great.

Many thanks
Jeanmac
 
K

KePaHa

I believe this will do so:

Sub Macro1()

With Application.Browser
.Target = wdBrowsePage
.Previous
End With

End Sub
 
J

jeanmac

Thaks for getting back to me. The code you gave me takes me to the top of
the previous page not the current one, I can't find the reference forthe
current page, can you help? Thanks.
 
A

Aminc

Try this:
Dim iGoTo ' declare variable to store value of current page

iGoTo = Selection.Information(wdActiveEndPageNumber) ' get and store current
page#
Selection.GoTo What:=wdGoTopage, Which:=wdGoToNext, Name:=2 ' go to page
number stored previously.

Cursor will be positioned on the first line before first char.
 
A

Aminc

sorry, Replace line "Selection.GoTo What:=wdGoTopage, Which:=wdGoToNext,
Name:=2" with "Selection.GoTo What:=wdGoTopage, Which:=wdGoToNext,
Name:=iGoTo"
 
J

jeanmac

Thank you for replying to my post. You have given me another very useful
piece of code and I appreciate it.

Jeanmac
 

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