I have a few functions that generate Word, Excel or PDF documents. For example, the one I'm working on is exporting a report to a PDF file. After closing the report, it opens another PDF form created with LiveCycle ES 8.2 and it fills it with data from a database. After this, the document is closed, but for some reason, the instance of Acrobat is still open in foreground with no document opened.
Here is the code:
DoCmd.OpenReport "myReport", acViewPreview
DoCmd.OutputTo acOutputReport, "", acFormatPDF, "C:\myReport.pdf", False
DoCmd.Close acReport, "myReport"
Dim gApp, avDoc, pdDoc, jso
Set gApp = CreateObject("AcroExch.app")
Set avDoc = CreateObject("AcroExch.AVDoc")
If avDoc.Open(exprPDF, "") Then
Set pdDoc = avDoc.GetPDDoc()
Set jso = pdDoc.GetJSObject
'[...]
pdDoc.Save PDSaveIncremental, FileNm 'Save changes to the PDF document
pdDoc.Close 'Close the PDF document
End If
avDoc.Close (True)
Set gApp = Nothing
Set avDoc = Nothing
myReport never opens any instance of Acrobat. The line avDoc.Open
does. I would like Acrobat to be closed when I do avDoc.close
. Any ideas?
After some more tests, I need to both close and quit all document objects to ensure that the app quits if there is no remaining opened document.