Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Print PDF files using Visual Basic

662 views
Skip to first unread message

McKilty

unread,
Sep 17, 2009, 1:31:59 PM9/17/09
to
I have an app that allows users to select multiple files and print
them regardless if they are Word, Excel, PowerPoint, or PDF files. It
works for everything but PDF files. I had it working on my computer,
but I had Acrobat 7. The rest of the staff has Acrobat 9 and when the
print, nothing happens.

So I installed Acrobat 9 and now nothing happens for me either. In
VB6, the reference I use is Adobe Acrobat 9.0 Type Library. The code
is as follows:

Public Sub AcrobatPrint(Filename As String)

Dim AcroExchApp As Acrobat.CAcroApp
Dim AcroExchAVDoc As Acrobat.CAcroAVDoc
Dim AcroExchPDDoc As Acrobat.CAcroPDDoc
Dim num As Integer

Set AcroExchApp = CreateObject("AcroExch.App")
Set AcroExchAVDoc = CreateObject("AcroExch.AVDoc")

' Open the [Filename] pdf file
AcroExchAVDoc.Open Filename, ""

' Get the PDDoc associated with the open AVDoc
Set AcroExchPDDoc = AcroExchAVDoc.GetPDDoc

' Get the number of pages for this pdf [and subtract one as zero
based]
num = AcroExchPDDoc.GetNumPages - 1
Call AcroExchAVDoc.PrintPages(0, num, 1, True, True)

AcroExchApp.Exit
AcroExchAVDoc.Close (True)
AcroExchPDDoc.Close

End Sub

It opens the file and gets the page count, but the print command is
pretty much ignored. Any ideas?

McKilty

unread,
Sep 17, 2009, 1:37:07 PM9/17/09
to
Sorry, wrong forum.
0 new messages