Ask Your Question

How do we import the listener events of LibreOffice writer in Visual Basic 6? [closed]

asked 2017-11-01 19:24:42 +0100

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.

I am trying to implement a listener event in Visual Basic 6 for LibreOffice Writer. I was referred to the following code from

set xContext = objServiceManager.getPropertyValue( "DefaultContext" )
set xCoreReflection = xContext.getValueByName( "/singletons/" )
set xClass = xCoreReflection.forName( "" )
set xMethod = xClass.getMethod( "addEventListener" )

dim invokeargs(0)
invokeargs(0) = myListener

set value = objServiceManager.Bridge_GetValueObject()
call value.InitInOutParam("[]any", invokeargs)
call xMethod.invoke( objDocument, value )

I am not able to understand the implementation of the listener event from this code.

Can I get example code to implement listener events for LibreOffice Writer in Visual Basic 6?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-07-25 22:12:07.569701


This was originally asked at

Jim K gravatar imageJim K ( 2017-11-02 17:35:37 +0100 )edit

1 Answer

Sort by » oldest newest most voted

answered 2017-11-02 19:46:19 +0100

Jim K gravatar image

updated 2017-11-02 19:49:53 +0100

Here is more complete _VB.NET_ code. Probably won't work in _VB6_ though.


Module Module1
    Sub Main()
        Dim oSM
        Dim oDesk, oDoc As Object
        Dim arg(-1)
        oSM = CreateObject("")
        oDesk = oSM.createInstance("")
        oDoc = oDesk.loadComponentFromURL("private:factory/swriter", "_blank", 0, arg)
        Dim xContainer As XContainer =  REM # TODO: Get object you want to listen to
        Dim myListener As MyListener = New MyListener()
    End Sub
    Class MyListener
        Implements XContainerListener
        Sub disposing(oEvent As EventObject) Implements XEventListener.disposing
        End Sub
        Sub XContainerListener_elementInserted([Event] As ContainerEvent) Implements XContainerListener.elementInserted
        End Sub
        Sub XContainerListener_elementRemoved([Event] As ContainerEvent) Implements XContainerListener.elementRemoved
        End Sub
        Sub XContainerListener_elementReplaced([Event] As ContainerEvent) Implements XContainerListener.elementReplaced
        End Sub
    End Class
End Module
edit flag offensive delete link more


Hi Jim,

Please let me know how to get object and assign for container.

Dim xContainer As XContainer = REM # TODO: Get object you want to listen to

Also provide me some example code (C# or VB.NET) to raise onSave event for libreoffice document.


Muru gravatar imageMuru ( 2017-11-10 06:21:13 +0100 )edit

@Muru: Please ask this as a separate question, and I will give an answer for C# (which I prefer instead of _VB.NET_). Since this will be your first question on this site, have a look at my suggested list at Especially be sure not to check the community wiki box. Then if your question is good enough, I'll upvote it to give you some reputation points, and you'll get points if you mark the answer as correct.

Jim K gravatar imageJim K ( 2017-11-10 20:53:47 +0100 )edit

Question Tools



Asked: 2017-11-01 19:24:42 +0100

Seen: 486 times

Last updated: Nov 02 '17