Search code examples
unolibreoffice-basiclibreoffice-baseopenoffice-basicopenoffice-base

How to fix :"Not Enough Stack Memory" when trying to load() with OfficeDatabaseDocument UNO service


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.


Solution

  • 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.