LibreOffice PrintEvent

I’m using LibreOffice with the OLE interface. Everything works fine.
Only one Problem. I want to send the Print command and after spooling closing the application.
But the close call does cancel the print progress.
I have to wait with the close call until the print progress is completed.
The print progress can take different time amounts so a timer isn’t a solution.

I’m searching for a solution to get the LibreOffice Print Event Listener.
( )

In LibreOfficeBasic the solution to my problem would be:

[code]Sub Register_PrintJobListener
Dim oPrintJobListener as Object

oPrintJobListener = CreateUnoListener( "PrintJobListener_", "" )

End Sub

Sub PrintJobListener_printJobEvent(oEvent)
End Sub

Sub PrintJobListener_disposing
end sub[/code]
But CreateUnoListener doesn’t exist in XOJO.

I tryed to use the OLEObject.EventTriggered Eventhandler and the createInstance function of the Service Manager, but the Service Manager couldn’t initialize the ( (Failed on createInstance))

[code]//Event Listener
Dim printEvent as PrintEventListener //Subclass of OLEObject

printEvent = objServiceManager.createInstance(“”)

I couldn’t find a solution to get the Event with OLE.

I also tried to Create a Object with two public methods named printJobEvent(oEvent as Variant) and disposing().
After using objDocument.addPrintJobListener(printEvent) on the Object I didn’t get an Error in XOJO but LibreOffice got a fatal error.

Any Ideas or working solutions?

It’s Christmas Holidays, so I just stumbler over it again.

The strange thing is. If you enter it as:

  Dim objServiceManager As OLEObject
  Dim printEvent as OLEObject
  objServiceManager = New OLEObject("")
  printEvent = objServiceManager.createInstance("")
  objServiceManager = nil
exception err as oleexception
  msgbox err.message

Then I don’t get any errors. Could it be something with your subclass ?