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

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Siddmonk
Posts: 3
Joined: Mon Feb 05, 2018 9:05 pm

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

Post by Siddmonk »

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
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Python resolver.resolve Attribute Error 'NoneType'

Post by RoryOF »

Have you a document open to which to connect?
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Siddmonk
Posts: 3
Joined: Mon Feb 05, 2018 9:05 pm

Re: Python resolver.resolve Attribute Error 'NoneType'

Post by Siddmonk »

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'

Post by Siddmonk »

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
Post Reply