Private Function XLSPages(FileName As String) As Long
Dim DocObj, theWorkSheets, theSheet
Set DocObj = CreateObject("Excel.Application")
Set theWorkSheets = DocObj.Workbooks.Open(FileName).Sheets
DocObj.Visible = False
For Each theSheet In theWorkSheets
theSheet.Activate
Debug.Print theSheet.Name
XLSPages = XLSPages + ExecuteExcel4Macro("Get.Document(50)")
Next
Debug.Print XLSPages
DocObj.Workbooks(Right(FileName, Len(FileName) - InStrRev(FileName, "\"))).Close False
DocObj.Quit
Set DocObj = Nothing
End Function