0

I try to familiarize myself with the usage of Macro and UNO API on LibreOffice Base, i tried to open my .odb file with the UNO OfficeDatabaseDocument (DOC here : https://api.libreoffice.org/docs/idl/ref/servicecom_1_1sun_1_1star_1_1sdb_1_1OfficeDatabaseDocument.html#a3d0b1f053d53f5b196e4c19e55a519ae ) to play with UNO and learn to use them.

Function MyClubOfficeDatabaseDocument()
    Dim MyClubURL(0) As New com.sun.star.beans.PropertyValue
    MyClubURL(0).Name = "Chemin d'accès vers la base de donnée MyClub"
    MyClubURL(0).Value = "/Users/faisalsalhi/Desktop/MyClub/MyClub.odb"

    MyClubOfficeDatabaseDocument = CreateUnoService("com.sun.star.sdb.OfficeDatabaseDocument")
    MyClubOfficeDatabaseDocument.load(MyClubURL)
End Function

I got a run time error saying that i have not enough stack memory to do this.

Ekiza
  • 31
  • 6

1 Answers1

0

You're running out of stack memory because you've set up an infinite recursion. That is, your function, MyClubOfficeDatabaseDocument, is called within itself, which then calls itself again, and again, and again, ad infinitum.

The only way to fix this is to eliminate the infinite recursion.

You should be able to fix it by simply changing either your function name or variable name. For example, you could change the function name to LoadMyClubOfficeDatabaseDocument.

David Yockey
  • 595
  • 3
  • 11
  • Okay i see, i tried to do this and solved the infinite recursion, thanks. But now, trying to load the document doesn't update the object MyClubOfficeDatabaseDocument, would you know why ? – Ekiza Aug 24 '19 at 18:01
  • It looks like the variable `MyClubOfficeDatabaseDocument` is local to the function, in which case it'd cease to exist when the function ends. To get around that, you need to declare `MyClubOfficeDatabaseDocument` outside of the function. Then it'll retain the value assigned to it inside the function. For lots more info on OO/LO Basic, pull down a copy of https://wiki.openoffice.org/w/images/e/e1/BasicGuide_OOo3.0.0.pdf. Pages 21-23 look to be particularly relevant to your current issue. – David Yockey Aug 24 '19 at 19:54