Page number using VBA.

J

Junaid

Hello,
Can I find out which page number the cursor is in a Word document using
VBA? I don't know what to look for in Word documentation. I searched for
'location', 'page number', or 'cursor location' in MS Word documentation
and didn't find anything. Could someone help me with that?

Thanks
Junaid
 
D

DeeJee

Can I find out which page number the cursor is in a Word document
using
VBA? I don't know what to look for in Word documentation. I searched for
'location', 'page number', or 'cursor location' in MS Word documentation
and didn't find anything. Could someone help me with that?

See answer "page number" 28/09/03

Msgbox "The cursor is on page " & _
Selection.Information(wdActiveEndPageNumber)
 
K

Kemosabe

Hello,
Can I find out which page number the cursor is in a Word document using
VBA? I don't know what to look for in Word documentation. I searched for
'location', 'page number', or 'cursor location' in MS Word documentation
and didn't find anything. Could someone help me with that?

Thanks
Junaid

Public Function CurrentPageNumber() As Integer

Dim iCurrentPage As Integer

On Error GoTo Page0
ActiveDocument.Repaginate
iCurrentPage = selection.Information(wdActiveEndPageNumber)

CurrentPageNumber = iCurrentPage
Exit Function

Page0:
CurrentPageNumber = 0

End Function
 

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