0

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!

procx
  • 43
  • 1
  • 1
  • 8
  • Do you really have such a Python module? That looks like a Java classpath, not a Python path. Are you using Jython? – Daniel Roseman Jul 06 '12 at 12:45
  • Yes this is my python code:) And its works perfect so...:) – procx Jul 06 '12 at 12:59
  • I don't understand what you're saying. It's obviously not working perfectly, as you are getting an error. – Daniel Roseman Jul 06 '12 at 13:09
  • The part of the code is working. I can make a document with some input, but i want to use tabstops in my document. The error is because the import fails. The code snip was just for extra information. – procx Jul 06 '12 at 13:16
  • Right. So you still haven't answered my question about whether you really have a Python module called "com.sun.star.style". As I say, it does seem very unlikely, because that's a Java classpath. – Daniel Roseman Jul 06 '12 at 13:23
  • com.sun.star.style is also a Python module. I found it around the internet several times as an import in Python, but i can't seem to find this specific error anywhere – procx Jul 06 '12 at 13:28
  • I didnt use the python version in openoffice. It is fixed now. – procx Jul 13 '12 at 09:30

1 Answers1

1

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.

procx
  • 43
  • 1
  • 1
  • 8