VBA to open a PDF file and print only certain pages

We needed to open a PDF file with VBA code and print only certain pages. We searched, but couldn't find a way to do it without buying a license to Adobe Acrobat Standard.

CODE:

Public Sub PrintPDFPartial(strFileName As String, intBeginPage As Integer, intEndPage As Integer)

'This works but requires Adobe Acrobat Standard

Dim AcroApp As AcroApp

Dim AcroAVDoc As AcroAVDoc

Dim AcroPDDoc As AcroPDDoc

Set AcroApp = CreateObject("AcroExch.App")

Set AcroAVDoc = CreateObject("AcroExch.AVDoc")

Const POSTSCRIPT_LEVEL = 2

If AcroAVDoc.Open(strFileName, vbNull) <> True Then

Exit Sub

End If

Set AcroAVDoc = AcroApp.GetActiveDoc

Set AcroPDDoc = AcroAVDoc.GetPDDoc

AcroAVDoc.PrintPages intBeginPage - 1, intEndPage - 1, POSTSCRIPT_LEVEL, True, False

AcroAVDoc.Close True

AcroApp.Exit

Set AcroDoc = Nothing

Set AcroApp = Nothing

End Sub