Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing The Printer Using VBA Code

Status
Not open for further replies.

ChrisBelzona

Programmer
Oct 25, 2000
137
GB
Hi

I have some code which I use in an Access Database to print .pdf (with Distiller). The code seems to open the pdf find the No of pages and prints them.

My problem is this I need to change the printer after it open the pdf (at the moment is just uses the default), I think I can do this from MSAccess, but think it could be easier from the code but I'm not sure. the code is below.

Any Help would be great

Sub PrintAllAcrobatDocsInDir(strFileName As String)
Dim AcroExchAVDoc As Object, AcroExchPDDoc As Object, _
AcroExchApp As Object
Dim iNumberOfPages As Integer

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

' Open the [strFileName] pdf file
AcroExchAVDoc.Open strFileName, ""
' 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]
iNumberOfPages = AcroExchPDDoc.GetNumPages - 1
' Print all pages in this document
AcroExchAVDoc.printPages 0, iNumberOfPages, POSTSCRIPT_LEVEL, True, False
' Close this file
AcroExchAVDoc.Close True


AcroExchApp.Exit
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top