Re: How to get page number with VBA in Word ?

Daniel was telling us:
Daniel nous racontait que :

It could be simple, but I can not find how to do it:

I need a code to get the page number of some range object, let me
say, I have a paragraph, and I want to know his location (page
number) when printed.

Did you see the post named : "How to get the current page number?" from 3
days ago?

In VBA you would use the Information property:

MsgBox Selection.Information(wdActiveEndPageNumber)
MsgBox Selection.Information(wdActiveEndAdjustedPageNumber)

where the first one gives you the absolute page count in the document and
the second the page number as defined in the Page Number formatting dialog
(Insert menu > Page Numbers...)


Jean-Guy Marcil - Word MVP
Word MVP site: