bottom
Great WordTips!
         
Your e-mail address is safe!
Close Note

Tips.Net > WordTips Home > Macros > VBA Examples > Determining the Number of Pages in Your Document

Determining the Number of Pages in Your Document

Summary: If your macro needs to know how many pages are in your document, you can use the Information method to get the desired info. It just takes a single line added to your macro. (This tip works with Microsoft Word 97, Word 2000, Word 2002, Word 2003, and Word 2007.)

There may be times in your macros when you need to determine the number of pages in a document. The following code will tell you the number of pages in a document:

TtlPgs = Selection.Information(wdNumberOfPagesInDocument)

After executing this code, the value of TtlPgs represents the total number of physical pages in the document.

Tip #726 applies to Microsoft Word versions: 97 | 2000 | 2002 | 2003 | 2007


Find and Replace Almost Anything! An invaluable resource for learning how to harness the full power of Word's search and replace capabilities. You'll discover everything you need in order to master all the intricacies of finding and replacing elements of your document, including the super-powerful ?wildcard searches? available in Word.
 
Check out WordTips: Find and Replace today!

Helpful Links

Ask a Word Question
Make a Comment

Tips.Net Home
Vital News Home

WordTips FAQ
WordTips Premium

Learn Access Now

Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips

Advertise on the
WordTips Site

 

Great Info!

Get tips like this every week in WordTips, a free productivity newsletter. Enter your e-mail address and click "Subscribe."
     
(Your e-mail address will never be shared with anyone, ever.)