On 09/21/10 16:24, Soohong Min wrote:
My issue is that I wanna move previous installed Openoffice to other machine which doesn't have any distribution package for Openoffice. I could launch it without any error but I tried to start it with python scritp as follows:---------------------------------------------------------------------------------------- import socket # only needed on win32-OOo3.0.0 import uno # get the uno component context from the PyUNO runtime localContext = uno.getComponentContext() # create the UnoUrlResolver resolver = localContext.ServiceManager.createInstanceWithContext( "com.sun.star.bridge.UnoUrlResolver", localContext ) # connect to the running office ctx = resolver.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" ) smgr = ctx.ServiceManager # get the central desktop object desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx) # access the current writer document model = desktop.getCurrentComponent() # access the document's text property text = model.Text # create a cursor cursor = text.createTextCursor() # insert the text into the document text.insertString( cursor, "Hello World", 0 ) ctx.ServiceManager ---------------------------------------------------------------------------- I got error msg at this part: localContext = uno.getComponentContext() AttributeError: 'module' object has no attribute 'getComponentContext
If you use a vanilla OOo (i.e., downloaded from openoffice.org), this should just work if you run the Python script with the Python interpreter bundled in the OOo installation (.../openoffice.org3/program/python).
-Stephan --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
