Ask Your Question

My Macros Python error with built-in script [closed]

asked 2016-07-29 10:07:26 +0200

Metazeta gravatar image

updated 2020-09-10 09:50:03 +0200

Alex Kemp gravatar image

Old topic

I encounter the same error as in this old topic above.

pyuno._createUnoStructHelper: member 'Context' of struct type '' not given a value.

I use the sample script HelloWorldPython with Libreoffice stable The sample script works perfectly when in the sample folder. I simply moved it to the My Macros folder and it threw the error.

I can't apply the fix detailed in the old topic as apparently it has been fixed in libreoffice updates (the "Scripts" folder has already a capital)

I tried in versions 4.4 and 5.1x64 but the error is exactly the same.

Edit : I installed the latest java x86 & x64, no progress...

Edit 2 : Here is the script.

def HelloWorldPython( ):
    """Prints the string 'Hello World(in Python)' into the current document"""
#get the doc from the scripting context which is made available to all scripts
    desktop = XSCRIPTCONTEXT.getDesktop()
    model = desktop.getCurrentComponent()
#check whether there's already an opened document. Otherwise, create a new one
    if not hasattr(model, "Text"):
        model = desktop.loadComponentFromURL(
            "private:factory/swriter","_blank", 0, () )
#get the XText interface
    text = model.Text
#create an XTextRange at the end of the document
    tRange = text.End
#and set the string
    tRange.String = "Hello World (in Python)"
    return None

Edit 3 : This annoying popup


edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2020-09-10 09:51:08.787210

1 Answer

Sort by » oldest newest most voted

answered 2016-07-29 16:48:26 +0200

updated 2016-08-05 03:46:18 +0200

In the same S.O.? Java It has nothing to do with it...

image description

Work fine in my system (ArchLinux, LibreOffice

With Win7 x64 and LibO 4.1

image description

Work fine your code in Win 7 Pro x64 with LibreOffice

image description Best regards

edit flag offensive delete link more


Same as the former post, I use Windows 7 64 bits (French). As for Java, I took my chance.

Metazeta gravatar imageMetazeta ( 2016-07-29 17:04:04 +0200 )edit

I test in Win7 x64 with LibO 4.1, work fine for me...

mauricio gravatar imagemauricio ( 2016-08-01 17:15:14 +0200 )edit

And it works when I put my own macros in the examples folder. At least there is a workaround ;-) Maybe it has a link with me having python 2.6 x86 on my machine ?

Metazeta gravatar imageMetazeta ( 2016-08-02 11:42:44 +0200 )edit

I don't think, show me your code for test

mauricio gravatar imagemauricio ( 2016-08-03 16:38:15 +0200 )edit

Ok, I edit my post with the script.

Metazeta gravatar imageMetazeta ( 2016-08-04 14:25:37 +0200 )edit

Work fine your code in Win 7 Pro x64 with LibreOffice

mauricio gravatar imagemauricio ( 2016-08-05 03:45:21 +0200 )edit

Question Tools

1 follower


Asked: 2016-07-29 10:07:26 +0200

Seen: 418 times

Last updated: Aug 05 '16