How to retrieve active page number from code?

R

Robert L

Hi All,

How can I retrieve active page number (the number that is displayed in the
status bar's left-most panel) from VBA code? I am using Word 2000.

Thank you in advance
Robert
 
D

David Mathi Raj via OfficeKB.com

Hi! Roby !!

Select INSERT menu, then select FIELD,
under the CATEGORIES, select NUMBERING
then under the field names select PAGE.

You got it.
 
J

Jean-Guy Marcil

Robert L was telling us:
Robert L nous racontait que :
Thank you very much for your help.

I am not sure how David's answer helped you. You asked about VBA code to get
the current page number, and he told you how to insert a page number on a
page...

If that is what you wanted, then great, and I must say he has a very good
crystal ball!

If not, look up the Selection.Information property:

'_______________________________________
Dim AbsolutePageNum As Variant
AbsolutePageNum = Selection.Information(wdActiveEndPageNumber)
'_______________________________________

will return the page count from the beginning of the document

'_______________________________________
Dim RelativePageNum As Variant
RelativePageNum = Selection.Information(wdActiveEndAdjustedPageNumber)
'_______________________________________

will return the page count according to manual changes (if a section was
restarted at some numbers, etc.)

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
R

Robert L

Hi Jean-Guy,

You are right. He answered something else, but I was quite busy at the time
I was reading the answer and moreover, in the meantime I decided not to
include page numbers in my macro output. So I just thanked him for his
answer. Anyway I see you are a good reader :) and a man who wants to give
the correct answer to the question.
I will try your procedure for sure and use in some future macros.

Thank you very much for your advice and help. I appreciate this much.
Regards,
Robert
 

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