Hi,
I'm working on an application that prints batches of documents with OMR in VB.net (OMR - are markings that allow the OMR enabled printer to fold documents etc into envelopes automatically)
As I'm printing these documents in batches for a number of people, I need to work on a document, print it with the OMR marks and then close/release it, move on to another document and then come back to the document when I'm on the next person and so fourth.
However, despite closing the PDDoc and AVDocument the document is still being kept open by Acrobat and an Acrobat process is running in my task manager.
Here is a brief snap shot of my code:
Public Sub PrintAdobeOMR(ByRef sFile As String) dim AcroAVDoc, AcroPDDoc as Object AcroAVDoc = CreateObject("AcroExch.AVDoc") AcroAVDoc.open(sFile, Dir(sFile)) AcroPDDoc = AcroAVDoc.GetPDDoc '.... OMRStuff happens here AcroAVDoc.PrintPagesSilent(0, AcroPDDoc.GetNumPages- 1, 2, False, False) 'close up PDDoc AcroPDDoc.Close() ReleaseActiveX(AcroPDDoc) 'code to try and release COM/ActiveX objects AcroPDDoc = nothing 'close AV Doc AcroAVDoc.Close(True) ReleaseActiveX(AcroAVDoc) AcroAVDoc = Nothing end sub Public Sub ReleaseActiveX(ByVal o As Object) 'ensures active X / Com objects are closed Try System.Runtime.InteropServices.Marshal.ReleaseComObject(o) Catch ex As Exception Finally o = Nothing End Try End Sub
As I said, the next time the application goes to open the document, I get an error saying the file is already open in Acrobat. I'm probably missing something simple but what....
Thanks
G