Derek,
I guess I jumped the gun. Acrobat Reader cannot be controlled through
automation. Acrobat, however, can. The code at the bottom automates
Acrobat to print. You can automate Excel as well. You don't need to add
references in Access if you use Late Binding. This involves declaring
objects as type Object and using CreateObject or GetObject to get a pointer
to said objects. Using CreateObject and GetObject require knowing the
correct class names. For Excel, you'll use "Excel.Application". For
Acrobat, you'll need "AcroExch.App", "AcroExch.AVDoc", and "AcroExch.PDDoc".
It can be worthwhile to use Early Binding (add a reference to Excel or
Acrobat and declare objects As Excel.Application, etc.) while in development
so that you get Intellisense help with object and can use the Object Browser
(F2) to identify methods and properties. Before I distribute code I like
switch back to Late Binding. I remove the reference and change any
Dim xlApp As Excel.Application
to
Dim xlApp as Object 'Excel.Application
HTH,
Kevin
'******************
Public Sub PrintAcrobatFile(strFile As String)
Dim avdoc As Object 'Acrobat.CAcroAVDoc
Dim pddoc As Object 'Acrobat.CAcroPDDoc
Dim app As Object 'Acrobat.CAcroApp
Dim iPages As Integer ' number of pages in document
On Error Resume Next
Set app = CreateObject("AcroExch.App")
If Err = 429 Then
MsgBox "The full Acrobat Program is not installed. Cannot automate
Acrobat unless it is.", vbOKOnly
Err.Clear
On Error GoTo 0
Exit Sub
End If
Set avdoc = CreateObject("AcroExch.AVDoc")
Set pddoc = CreateObject("AcroExch.PDDoc")
'Show Acrobat if you'd like
'app.Show
pddoc.Open strFile 'Open the file
' count the pages of the document
iPages = pddoc.GetNumPages
'proceed only if the document has pages / is not null
If iPages > 0 Then
Set avdoc = pddoc.openAVDoc(strFile)
'print the 0-based index of pages
avdoc.PrintPages 0, iPages - 1, 1, False, False
avdoc.Close True
End If
pddoc.Close
Set avdoc = Nothing
Set pddoc = Nothing
If Not (app Is Nothing) Then app.Exit
Set app = Nothing
End Sub