Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
WD2002: Information (wdActiveEndPageNumber) Property Returns Incorrect Ending Page Number
Article ID: 274003 - View products that this article applies to.
This article was previously published under Q274003
For a Microsoft Word 2000 version of this article, see 241714
When you use the wdActiveEndPageNumber Information property in a Word macro, the macro may return an incorrect ending page number.
This problem may occur when all of the following conditions are true:
Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. NOTE: This sample macro may not work correctly in all circumstances.
In the macro, select the range for which you want to retrieve the number of the last page in the range, and use the Selection object instead of the Range object.
If you use the Selection object, it may be a good idea to store the current selection at the beginning of the macro in a Range variable and to set the selection back to its original value at the end of the code that retrieves the page number.
The following sample macro loops through all tables in a document and displays the number of the last page on which each table is located in a message box. It also shows how to store the selection in a Range variable and restore it at the end of the macro. The macro turns the screen updates off (which is optional) and can be used to hide the movement of the selection in the document when the macro is running:
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
The following actions also may help to ensure that the page number is retrieved correctly: