Question

I'm trying to import a TabStop into my Python script to create an openoffice document. Only i keep getting this error:

Traceback (most recent call last):
  File "C:\Users\Sander\Desktop\macroTest.py", line 10, in <module>
    from com.sun.star.style import TabStop
ImportError: No module named com.sun.star.style

This is a part of the code i use to create a document:

from win32com.client import Dispatch as Dispatch
svm = Dispatch("com.sun.star.ServiceManager")
coreflect = svm.createInstance("com.sun.star.reflection.CoreReflection")
desktop = svm.createInstance("com.sun.star.frame.Desktop")
doc = desktop.loadComponentFromURL("private:factory/swriter", "_blank",0, [])
default = doc.StyleFamilies.getByName("PageStyles").getByName("Default")
txt = doc.getText()
cur = txt.createTextCursor()

The line it goes wrong:

from com.sun.star.style import TabStop 

Anybody knows how to fix this import?

Thanks in advance!

Was it helpful?

Solution

I have fixed this problem. I used a installed version of Python 2.7. I found a python.exe in the openoffice folder. When i use that executable the imports work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top