I have an Access application where I create a PDF file from a report. After
creating it I add a digital signature, then save it. I use the following
code:
Set pdfPDDoc = pdfAVDoc.GetPDDoc
blOK = pdfPDDoc.Save(1, ReportName)
If (blOK = False) Then
AddSignature = "*** ERROR *** Could not save " & ReportName & "
after adding digital signature"
Else
AddSignature = "OK"
End If
When closing the sub I clean up, as follows:
If Not (pdfAVDoc Is Nothing) Then
pdfAVDoc.Close 0
Set pdfAVDoc = Nothing
End If
If Not (pdfPDDoc Is Nothing) Then
pdfPDDoc.Close
Set pdfPDDoc = Nothing
End If
This worked reliably in Acrobat 5, in Acrobat 6 it hangs the Access
application, until I use Task Manager to kill an orphan Acrobat.exe process.
In Acrobat 5 I had tried creating an AcroExch.App, as I had seen in some
examples, but that crashed Access so I found I could do without the App
object. I have not tried reintroducing the App object yet.
Any comments or advice would be appreciated.
Ragnar
' Only allows 1 App Object so will either create a new one or attach to an existing one
Set PDDOC = Nothing
Set AVDOC = Nothing
Set AVPageView = Nothing
Set GApp = CreateObject("Acroexch.app")
r = GApp.CloseAllDocs
r = GApp.Exit
We have this as a function and run it at the end of any code using Acrobat objects
Alex
What I do is, just before printing report, is to change the default printer
to Win2PDF, or PDFWriter.
This causes the report to be outputted as a PDF file instead of sent to the
regular default printer. Afterwards I reset the default printer.
To avoid getting prompted for a filename I set the fully qualified filespec
in the Registry. When the report is processed the Win2PDF or PDFWriter
clears the Registry setting.
Win2PDF is sold by Dane Prairie LLC, $35.-, PDFWriter comes with Adobe
Acrobat 5 (Not Acrobat Reader) or earlier, not included with Acrobat 6.
The code for changing the default printer I got from Access Developer's
Handbook by Litwin, Getz and Gilbert. You can also find this on
http://www.mvps.org/access/reports/rpt0011.htm including what setting in the
Registry to change for PDFWriter.
Win2PDF will give information on where to set the filespec in the Registry,
including code samples. Win2PDF is supposed to be compatible with all
versions of PDF files.
Be aware that PDFWriter is supposedly not good at handling complex graphics.
I have not had any problems with creating simple Access reports, or even
fairly complex Excel spredsheets, which do contain a certain amount of
graphics in order to look like an Excel spreadsheet.
Ragnar