Folks,

I am trying to print out pdfs from within an Access VBA program. At the moment I simply pass a command line and call reader using:

strCommand = """" & AcrobatLocation & """ /h /t """ & PdfFileName & """ """ & PrinterName & """"
lngProID = Shell(strCommand, vbHidden)

which works up to a point.

The problems are, a) it is very slow b) I can't trap errors - for example if the pdf is a non-printable document the program just sits and waits and c) I have to close Acrobat Reader by using the sendkeys function to send a"F4" - it works but if someone opens a different window the sendkeys closes that one instead.

So what I want to do is create an Acrobat object with VBA and then use that to print out a file. I looked at the Adobe web site and copied some code from there just to try it out and get a "Active X cant create the object" error message.

For example if I have the following code in VBA, with the Acrobat 7.0 Type Library reference

public Sub Test()
Dim gApp As Acrobat.CAcroApp
Dim gPDDoc As Acrobat.CAcroPDDoc
Dim jso As Object
gApp = CreateObject("AcroExch.App")
gPDDoc = CreateObject("AcroExch.PDDoc")
If gPDDoc.Open("c:\adobe.pdf") Then
jso = gPDDoc.GetJSObject
jso.console.Show
jso.console.Clear
jso.console.println ("Hello, Acrobat!")
gApp.Show
End If
end sub

then it fails at the first CreateObject line with the error "ActiveX cant create object"

I have posted on the access forum but not got an answer to this specific problem - any help would be greatly appreciated.

John