'''Library Shell32
''' C:\WINDOWS\system32\SHELL32.dll
''' Microsoft Shell Controls And Automation
'''Library Word
''' C:\Program Files\Microsoft Office\OFFICE11\MSWORD.OLB
''' Microsoft Word 11.0 Object Library
'### Constante à adapter ###
Const CHEMIN_DOSSIER As String = "C:\Test"
'###########################
Sub NbPagesAllDoc()
Dim SH As Object 'As Shell32.Shell
Dim FoldIT As Object 'As Shell32.FolderItem
Dim FOL As Object 'As Shell32.Folder
Dim AppWord As Object 'As Word.Application
Dim myDoc As Object 'As Word.Document
Dim nbDoc&
Dim nbPages&
Dim nbTotalPages&
Set SH = CreateObject("Shell.Application")
Set FOL = SH.Namespace(CHEMIN_DOSSIER)
For Each FoldIT In FOL.Items
If FoldIT.isFolder = False Then
If LCase(Right(FoldIT, 4)) = ".doc" Then
nbDoc& = nbDoc& + 1
If AppWord Is Nothing Then Set AppWord = CreateObject("Word.Application")
Set myDoc = AppWord.Documents.Open(CHEMIN_DOSSIER & "\" & FoldIT & "")
nbPages& = myDoc.Windows(1).Panes(1).Pages.Count
nbTotalPages& = nbTotalPages& + nbPages&
myDoc.Close 0 'wdDoNotSaveChanges
Set myDoc = Nothing
End If
End If
Next FoldIT
If Not AppWord Is Nothing Then
AppWord.Quit
Set AppWord = Nothing
End If
MsgBox nbTotalPages & " pages dans " & nbDoc& & " fichier(s) .doc"
End Sub