VBA code for Printing PDF file

0 Votes

VBA code for Printing PDF file

I am working on a MA Access projct that I would like to Print a selected PDF file and close adobe reader after it is printed. I have tried several different things and can't get it to work. I can get it to open the file in Adobe but can't seem to get it to print the file and close. Can anyone give me some examples or steer me in the right direction.
0 Votes

Here is the code:

Dim AcroApp As CAcroApp
Dim AVDoc As CAcroAVDoc
Dim PDDoc As CAcroPDDoc
Dim IsSuccess As Boolean

Set AcroApp = CreateObject("AcroExch.App")
Set AVDoc = CreateObject("AcroExch.AVDoc")

AVDoc.Open "c:\windows\desktop\back_cover.pdf", ""

Set PDDoc = AVDoc.GetPDDoc

AVDoc.PrintPages 1, 1, 2, True, True

'Close the PDF
AVDoc.Close True

Set PDDoc = Nothing
Set AVDoc = Nothing
Set AcroApp = Nothing

Exit Sub

0 Votes

This looks similar to the other codes I've written and I get the same result. I get error and it highlights the line.......

[Set AcroApp = CreateObject("AcroExch.App")]