Ask Your Question
0

My Macros Python error with built-in script

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

Metazeta gravatar image

updated 2016-08-05 11:19:23 +0200

Old topic

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

pyuno._createUnoStructHelper: member 'Context' of struct type 'com.sun.star.uno.Exception' not given a value.

I use the sample script HelloWorldPython with Libreoffice stable 5.0.6.3. 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

Printscreen

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

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

mauricio gravatar image

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 5.0.6.3)

With Win7 x64 and LibO 4.1

image description

Work fine your code in Win 7 Pro x64 with LibreOffice 5.1.5.2

image description Best regards

edit flag offensive delete link more

Comments

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 5.1.5.2

mauricio gravatar imagemauricio ( 2016-08-05 03:45:21 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

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

Seen: 305 times

Last updated: Aug 05 '16