Get number of pages in pdf

Share this post
FaceBook  Twitter  Mixx.mn     


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

2) Open PDF document

3) Get no of pages

Code:

'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
         Else
          GetNumPagesInPDF = -1
          End If
End Function