[Solved] Python resolver.resolve Attribute Error 'NoneType'

Keyboard macros or custom scripts

[Solved] Python resolver.resolve Attribute Error 'NoneType'

Postby Siddmonk » Mon Feb 05, 2018 9:24 pm

Hello All,
I'm trying to follow a tutorial on github ("openoffice-libreoffice-automate-your-office-tasks-with-python-macros"), and I can only get about 5 lines in before I raise an error.

Import socket
import uno

localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext('com.sun.star.bridge.UnoResolver', localContext)
ctx = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'NoneType' object has no attribute 'resolve'

This is all entered from the python shell in OpenOffice 4\programs\python.exe

I've scoured the forum(and the web in general) but I haven't seen anyone encounter this error. If anyone can point me in the right direction i would certainly appreciate it.
Last edited by Siddmonk on Mon Feb 05, 2018 10:16 pm, edited 2 times in total.
OpenOffice 4, Windows 10 Pro
Siddmonk
 
Posts: 3
Joined: Mon Feb 05, 2018 9:05 pm

Re: Python resolver.resolve Attribute Error 'NoneType'

Postby RoryOF » Mon Feb 05, 2018 9:45 pm

Have you a document open to which to connect?
Apache OpenOffice 4.1.5 on Xubuntu 18.04 (mostly 64 bit version) and infrequently on Win2K/XP
User avatar
RoryOF
Moderator
 
Posts: 27365
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Python resolver.resolve Attribute Error 'NoneType'

Postby Siddmonk » Mon Feb 05, 2018 9:48 pm

Yes the document was also launched from the command line soffice --writer "accept=socket,host=localhost,port=2002;urp;"
And is open when I make the call to resolver.resolve
OpenOffice 4, Windows 10 Pro
Siddmonk
 
Posts: 3
Joined: Mon Feb 05, 2018 9:05 pm

Re: Python resolver.resolve Attribute Error 'NoneType'

Postby Siddmonk » Mon Feb 05, 2018 10:15 pm

Just realized I had installed uno globally and wasn't sure if that would cause an error. So I uninstalled it and I no longer get the error. Thank you for your help.
OpenOffice 4, Windows 10 Pro
Siddmonk
 
Posts: 3
Joined: Mon Feb 05, 2018 9:05 pm


Return to OpenOffice Basic, Python, BeanShell, JavaScript

Who is online

Users browsing this forum: No registered users and 2 guests