PDA

View Full Version : Solved: How to determine total number of pages



presence76
03-01-2006, 07:19 AM
I am writing a macro that reads through a folder of word documents (approximately 3000) and needs to determine which ones are 1 page, 2 pages, and 3 pages. Then, these are seperated to associated folders. I tried to use

TotPages = ThisDocument.ComputeStatistics(wdStatisticPages)


But it gives me a value of 1 on the 2 pages.

Is there another variable that tells me the total pages in the current document?

Thanks in advance.

Andy Pope
03-01-2006, 08:58 AM
Hi,

Does ThisDocument refer to the document where the actual code resides?
I think you need to use ActiveDocument.

Jacob Hilderbrand
03-01-2006, 08:59 AM
Try this:

Option Explicit

Sub Macro1()

Dim Pages As Long

Pages = Selection.Information(wdNumberOfPagesInDocument)
MsgBox Pages

End Sub

presence76
03-01-2006, 09:08 AM
Jake - everything is Jake. Thanks a bunch. Works like a charm.

Jacob Hilderbrand
03-01-2006, 10:09 AM
Glad to help :beerchug:

Take Care