PyUNO connection to OpenOffice

Enrique Castro ecastro at
Tue Jun 10 15:29:38 CEST 2003

 >>No I can't. "telnet localhost" or "telnet" failed
 >>After a little exploration I found "telnet service
 >>management" under administrative tools (I am translating
 >>from names in spanish), and turned on the telnet service.
 >>Now if I do
 >>c:>telnet localhost , I do connect to
 >>c:>telnet localhost:2002 (or whatever other number) fails
 > Under Windowws, 'telnet' takes its port argument without
 > the colon separator.  Try this instead:
 >  telnet localhost 2002
 > You can also type "netstat -an" and see whether there is
 > anything LISTENING on port 2002, either on, your
 > regular address, or (which means "any interface").

I am a newbie and these details are a world for me. Thanks 
to Skip and Peter for being patient with my ignorance.

After checking "netstat -an", as suggested, there is NO 
entry for anythig listening at port 2002. Either OpenOffice 
is running or not.

Now the main question is how to access OpenOffice from 
Python. Why PyUNO fails with the error:

c:\Archivos de programa\OpenOffice.org1.1\program>python
Traceback (most recent call last):
   File "", line 27, in ?
     smgr = resolver.resolve( 
.ServiceManager" ) 
Connector : couldn't connec
t to socket (WSAECONNREFUSED, Connection refused)

The script should start a new OpenOffice 
instance, so I do not really understand what should be 
listening at :2002.

What do I need to setup to get the PyUNO connection working?
(I have appended the offending Python code at the end of the 

Is there a way to access OpenOffice through COM? (I have 
used COM to automate MS-Office). Is there a COM object 
map/tutorial for OpenOffice?

Thanks in advance


These are the first lines of the demo script that 
ships with PyUNO

# bootstrap uno component context 	
import uno
import unohelper

# a UNO struct later needed to create a document
from import AS_CHARACTER
from import Size

def insertTextIntoCell( table, cellName, text, color ):
     tableText = table.getCellByName( cellName )
     cursor = tableText.createTextCursor()
     cursor.setPropertyValue( "CharColor", color )
     tableText.setString( text )

localContext = uno.getComponentContext()
unohelper.addComponentsToContext(  localContext , localContext,
				   "" )
resolver = 
				"", localContext )

smgr = resolver.resolve( 
)   <--------- This is the offending line.
remoteContext = smgr.getPropertyValue( "DefaultContext" )

More information about the Python-list mailing list