Function DocPages(FileName As String) As Integer
Documents.Open FileName
Set myRange = ActiveDocument.Content
myRange.Collapse Direction:=wdEnd
Documents(1).Repaginate
DocPages = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages).Value
Documents(1).Close False
End Function