My Macros Python error with built-in script

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

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

Work fine in my system (ArchLinux, LibreOffice 5.0.6.3)

With Win7 x64 and LibO 4.1

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


Best regards

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

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

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

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

Ok, I edit my post with the script.

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