I am trying to write a macro that will give me a page count for all .doc in a folder. I have the code below. It works incrementing through the .docs but it returns the wrong page count. If there is 125 pages it will return 119.
Sub documentPageCount()
Dim oApp As Object
Dim oDoc As Object
Dim oTbl As Object
Dim sMyDir As String
Dim sDocName As String
'Start Word and open the document.
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
' The path to obtain the files.
sMyDir = "C:\temp\"
sDocName = Dir(sMyDir & "*.DOC")
While sDocName <> ""
Set oDoc = oApp.Documents.Open(sMyDir & sDocName)
x = oDoc.Content.Information(wdActiveEndPageNumber)
oDoc.Close False
sDocName = Dir()
Wend
oApp.Quit
End Sub
Sub documentPageCount()
Dim oApp As Object
Dim oDoc As Object
Dim oTbl As Object
Dim sMyDir As String
Dim sDocName As String
'Start Word and open the document.
Set oApp = CreateObject("Word.Application")
oApp.Visible = True
' The path to obtain the files.
sMyDir = "C:\temp\"
sDocName = Dir(sMyDir & "*.DOC")
While sDocName <> ""
Set oDoc = oApp.Documents.Open(sMyDir & sDocName)
x = oDoc.Content.Information(wdActiveEndPageNumber)
oDoc.Close False
sDocName = Dir()
Wend
oApp.Quit
End Sub