Error Access2Base (python) executing XSCRIPTCONTEXT.getDocument

Hello.

I am trying to create a macro in python with access2base.

According to the documentation, when doing from access2base import *, it should import the variable XSCRIPTCONTEXT that references module uno (XScriptContext).

Both XSCRIPTCONTEXT in python and the XScriptContext interface have the getDocument method, but if I try to use the method, for example, by running doc = XSCRIPTCONTEXT.getDocument() after the import from access2base, I get the following error:

image

What am I doing wrong?

Version: 7.5.3.2 (X86_64) / LibreOffice Community
Build ID: 9f56dff12ba03b9acd7730a5a481eea045e468f3
CPU threads: 16; OS: Windows 10.0 Build 22621; UI render: Skia/Raster; VCL: win
Locale: es-ES (es_ES); UI: es-ES
Calc: CL threaded Jumbo

Simply abstain from “access2base”?

What happens when you open some document and run

def dummy():
   doc = XSCRIPTCONTEXT.getDocument()

Yes, I know that.
But I need (I want) to use access2base and I’m having that problem.
I know I can miss import XSCRIPTCONTEXT from access2base too, but my question arises just in case somebody know what is my error or if it is an access2base error or there are any other solution

Why should anybody (other than the author of a2b) know the answer to this esotheric question?

May be the author of a2b use to read this forum :wink: or perhaps somebody has had the same problem and know a better way to solve it or perhaps my question don’t have any solution and if somebody read this post it will stop looking around for a solution.

I can reproduce the error on my system. It looks like a library error to me, as it “delete” the reference to XSCRIPTCONTEXT. I’ll check the code and let you know.

Version: 7.4.7.2 / LibreOffice Community
Build ID: 40(Build:2)
CPU threads: 16; OS: Linux 6.3; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
7.4.7-2
Calc: CL

Not posting your code for inspection…
.
If I read the error right, it happens at line 171 of your code. Is this the first reference to XSCRIPTCONTEXT ?

Yes, it is the unique reference, just used to test. It is from a macro into a .odb file.
I don’t think is an error in my code, but a kind o error in access2base, but I’m trying to see if somebody has the same problem and if somebody has solved it or found a workaround.
Just with this code you can reach the error

# coding: utf-8
from __future__ import unicode_literals
import uno
from access2base import *


def puebas(event=None):
    Application.OpenConnection()
    doc = XSCRIPTCONTEXT.getDocument()
    return

image

The author of a2b watches this forum on a regular basis, but, nevertheless and sorry for that, it might happen for good reasons that he remains far from his PC for a number of days … :face_with_open_eyes_and_hand_over_mouth:

Use simply:

# coding: utf-8
from __future__ import unicode_literals
import uno
from access2base import *


def puebas(event=None):
    Application.OpenConnection()
    doc = THISDATABASEDOCUMENT
    return