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

Using Acrobat w/ Automation in VBA

1,055 views
Skip to first unread message

sende...@hotmail.com

unread,
Aug 12, 1999, 3:00:00 AM8/12/99
to
I'm trying to use Acrobat 4.0 as an Automation server with
Microsoft Access. When I installed Acrobat, the Acrobat type
library (acrobat.tlb) showed up as an available reference in
my project, but when I set references to it, it was marked
"MISSING". I tried moving it to the System folder (the
original location was Program Files\Adobe\Acrobat
4.0\Acrobat) and this seems to have solved the problem, but
now when I try to instantiate the application in my code I
get the runtime error "ActiveX component can't create
object". It's not a registration issue, is it? Everything
that I think needs to be registered (FdfAcX.dll, FdfTk.dll,
and pdf.ocx) is already registered in the System folder.
Here's the code I have so far and where the error
occurs (to clarify things, I have a combo box on a form
where a user can select one of several PDF forms, which are
then filled in with information from the current record,
which comes via an FDF file associated with that record).

Private Sub cboShowForm_AfterUpdate()

Dim AcrApp As CAcroApp
Dim AcrDoc As CAcroAVDoc
Dim AcrForm As AFormApp
Dim AcrFields As AFORMAUTLib.Fields
Dim db As Database
Dim strPath As String
Dim strPDF As String 'pathname of PDF form to populate
Dim strFDF As String 'pathname of FDF file associated
with client
Dim blnFileFound As Boolean

Set db = CurrentDb()
strPath = "\\Server\c\MIRC Databases\"
strPDF = strPath & Me!cboShowForm & ".pdf"
strFDF = strPath & Me!ClientID & "_" & Me!cboShowForm &
".fdf"
Set AcrApp = CreateObject("CAcroApp")<-error occurs here
AcrApp.Show ^^^^^^^^^^^^^^^^^^^^^^^^
Set AcrDoc = CreateObject("CAcroAVDoc")

OpenFDF:
blnFileFound = AcrDoc.Open(strFDF, vbNullString)
If Not blnFileFound Then
Call CreateNewFDF(strFDF, strPDF)
Resume OpenFDF
End If

End Sub

Private Sub CreateNewFDF(strFDF As String, strPDF As String)

Dim FDFAcX As FDFACXLib.FdfApp
Dim FDFOutput As FDFACXLib.FdfDoc
Dim strFirstName As String
Dim strMiddleName As String
Dim strLastName As String

strFirstName = Me!ClientFirstName
strMiddleName = Me!ClientMiddleName
strLastName = Me!ClientLastName

Set FDFAcX = CreateObject("FdfApp.FdfApp")
Set FDFOutput = FDFAcX.FDFCreate

With FDFOutput
.FDFSetValue "First Name", strFirstName, False
.FDFSetValue "Middle Name", strMiddleName, False
.FDFSetValue "Last Name", strLastName, False
.FDFSetFile strPDF 'Associate FDF file with PDF file
.FDFSaveToFile strFDF 'Create FDF file on disk
.FDFClose 'Close FDF file
End With

Set FDFOutput = Nothing 'dereference FDF file
Set FDFAcX = Nothing 'dereference instance of FDF
application

End Sub


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.

Chris Henson

unread,
Aug 12, 1999, 3:00:00 AM8/12/99
to

Your CreateObject is trying to create the wrong object, it should be the
following:

Set AcroApp = CreateObject("AcroExch.App")
Set AcroAVDoc = CreateObject("AcroExch.AVDoc")
Set AcroPDDoc = CreateObject("AcroExch.PDDoc")
etc.....

------------------------------
Chris Henson
Image Conversions & Management
Web : www.icmconv.com
Email: chr...@icmconv.com
------------------------------


sende...@hotmail.com

unread,
Aug 13, 1999, 3:00:00 AM8/13/99
to
In article <y2Cs3.106$Zi4.2592@client>,
"Chris Henson" <chr...@icmconv.com> wrote:

>
> Set AcroApp = CreateObject("AcroExch.App")
> Set AcroAVDoc = CreateObject("AcroExch.AVDoc")
> Set AcroPDDoc = CreateObject("AcroExch.PDDoc")
> etc.....

Thanks--I tried this and it works. There are a couple of things that
still annoy me, though. I have a button on my Access form that closes
Acrobat, but first saves the data in the open PDF form to an FDF file.
Thus I don't want users closing the Acrobat window themselves, since the
data will be lost. Is there some way I can disable the close button on
the document and application windows for Acrobat? I'm sure there's an
API call somewhere that does that, but I have no idea what it is.
Also, when I close Acrobat from within my application it displays a
dialog box asking the user if they want to save changes to the open PDF
document. This dialog is not just annoying, but dangerous since I don't
want the user saving *any* changes to the document. I thought I got rid
of it by changing my preferences to "Skip Editing Warnings", but while
this works when I start Acrobat from the desktop, the dialog box still
appears when I start Acrobat using Shell or Automation. How can I get
rid of it in my application? Finally, I messed around a bit with the
OpenInWindowEx method of the AVDoc object, but am too ignorant of what
all the parameters mean to get it to work. Is there a good example
somewhere? TIA.

Brian Engel

unread,
Aug 13, 1999, 3:00:00 AM8/13/99
to

I have had the same problem with Distiller ActiveX Lib. I can't tell
you why this worked for me but try this....

Set AcrApp = New CAcroApp, instead of your Set Acrapp=Createobject _
("CAcroApp")

I have no Idea why the createobject keyword doesn't work.. probably an
Adobe feature :) .

In article <7otaud$7vo$1...@nnrp1.deja.com>,


sende...@hotmail.com wrote:
> Set AcrApp = CreateObject("CAcroApp")<-error occurs here
> AcrApp.Show ^^^^^^^^^^^^^^^^^^^^^^^^
> Set AcrDoc = CreateObject("CAcroAVDoc")
>
> OpenFDF:
> blnFileFound = AcrDoc.Open(strFDF, vbNullString)
> If Not blnFileFound Then
> Call CreateNewFDF(strFDF, strPDF)
> Resume OpenFDF
> End If
>
> End Sub
>

> Private Sub CreateNewFDF(strFDF As String, strPDF As String)
>
> Dim FDFAcX As FDFACXLib.FdfApp
> Dim FDFOutput As FDFACXLib.FdfDoc
> Dim strFirstName As String
> Dim strMiddleName As String
> Dim strLastName As String
>
> strFirstName = Me!ClientFirstName
> strMiddleName = Me!ClientMiddleName
> strLastName = Me!ClientLastName
>
> Set FDFAcX = CreateObject("FdfApp.FdfApp")
> Set FDFOutput = FDFAcX.FDFCreate
>
> With FDFOutput
> .FDFSetValue "First Name", strFirstName, False
> .FDFSetValue "Middle Name", strMiddleName, False
> .FDFSetValue "Last Name", strLastName, False
> .FDFSetFile strPDF 'Associate FDF file with PDF file
> .FDFSaveToFile strFDF 'Create FDF file on disk
> .FDFClose 'Close FDF file
> End With
>
> Set FDFOutput = Nothing 'dereference FDF file
> Set FDFAcX = Nothing 'dereference instance of FDF
> application
>
> End Sub

0 new messages