Question Locked

VBA code for Printing PDF file

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
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.

3 replies

by peconet tietokoneet

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

AcroApp.Show
AVDoc.PrintPages 1, 1, 2, True, True

'Close the PDF
AVDoc.Close True
AcroApp.Exit

'Cleanup
Set PDDoc = Nothing
Set AVDoc = Nothing
Set AcroApp = Nothing

Exit Sub

by dsivik

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")]

This discussion is closed to new replies.