Get number of pages in pdf

Share this post
FaceBook  Twitter     

To retrieve total no of pages in a PDF document, use following code:
1) Create an  AcroExch  object

2) Open PDF document

3) Get no of pages


'1.Function to get number of pages in pdf
Function GetNumPagesInPDF(FileName)
    Dim oPDFDoc
'1) Create an  AcroExch  object'    
     Set oPDFDoc = CreateObject( "AcroExch.PDDoc" )

'2) Open PDF document     
         If oPDFDoc.Open( FileName ) Then
'3) Get no of pages '         
         GetNumPagesInPDF = oPDFDoc.GetNumPages()
         Set oPDFDoc = Nothing
          GetNumPagesInPDF = -1
          End If
End Function