Early binding works, late binding doesn't

  • Thread starter Tom van Stiphout
  • Start date
T

Tom van Stiphout

Hi All,
This one got me stumped. Under what conditions would similar late
binding code fail where the early binding code works?

I'm using Wndows XP, Access 2003, and Adobe Acrobat 6 Pro. All at
latest service pack. The goal is to convert a postscript file to a PDF
file using Distiller's FileToPDF method.

This early binding code works:
'Ensure you have a reference to Adobe.Distiller
Const PS_FILENAME As String = "c:\junk\junk.ps"
Const PDF_FILENAME As String = "c:\junk\junk.pdf"
Dim objDistiller As New ACRODISTXLib.PdfDistiller
objDistiller.FileToPDF PS_FILENAME, PDF_FILENAME, ""
Set objDistiller = Nothing

This late binding code does not work. Both GetObject and CreateObject
fail with Err=429=ActiveX component can't create object. I tried a
different machine - same problem.
Why?
Const PS_FILENAME As String = "c:\junk\junk.ps"
Const PDF_FILENAME As String = "c:\junk\junk.pdf"
Const DISTILLER_CLASS As String = "ACRODISTXLib.PdfDistiller"
Dim objDistiller As Object
On Error Resume Next
Set objDistiller = GetObject(, DISTILLER_CLASS) ' <==
Err=429=ActiveX component can't create object
If Err.Number <> 0 Then
Err.Clear
Set objDistiller = CreateObject(DISTILLER_CLASS) ' <==
Err=429=ActiveX component can't create object
If Err.Number <> 0 Then
Err.Clear
MsgBox "Unable to create Distiller object. Acrobat not
installed?", vbCritical
End If
End If
On Error GoTo 0
If Not objDistiller Is Nothing Then
objDistiller.FileToPDF PS_FILENAME, PDF_FILENAME, ""
End If
Set objDistiller = Nothing

Thanks for any insights,
-Tom.
 
J

Jamie Carper

Hi Tom,

You are instantiating the wrong library to make this work.

Try this:

SET MyPDF = CreateObject( "PDFDistiller.PDFDistiller.1" )

Also whenever you do late binding you must declare all constants used
in any call to this library. Late binding does not pick up any
includes in the source.


Jamie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top