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

Closing PDF file in VBA code hangs MS Access app

626 views
Skip to first unread message

Ragnar_M...@adobeforums.com

unread,
Feb 27, 2004, 12:25:24 PM2/27/04
to
Hi,

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


Alex_...@adobeforums.com

unread,
Mar 1, 2004, 1:00:12 AM3/1/04
to
Ragnar
Thanks for the Post to my PrintPagesEx, i learnt with Acrobat 5 that you need to close the App object everytime and it doesn't hurt to do this at the start to ensure no previous code has left one behind.

' 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

Peter_G...@adobeforums.com

unread,
Mar 24, 2004, 6:07:37 PM3/24/04
to
I MS Access you can use the command "docmd.SendObject acSendReport,"reportname",acFormatRTF" to create a report in Rich Text format and attach it to outlook for sending. The problem with this way is that it RTF does not support graphics. You can choose a different format like HTML but the report looses its original design (borders change etc). Do you or anyone else know a way of doing the same thing except have the report formated in PDF? If so how do you do it?

Ragnar_M...@adobeforums.com

unread,
Mar 25, 2004, 10:19:14 AM3/25/04
to
Hello Peter.

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


0 new messages