Beim Erstellen eines neuen Dokuments aus einer Dokumentvorlage soll ein Makro starten, das in der Dokumentvorlage liegt.
Das Dokument erscheint wie gewünscht als 'Unbenannt 1', allerdings mit folgender Fehlermeldung:
Meldung: <class 'uno.com.sun.star.uno.RuntimeException'>: Couldn't convert file url to a system path for reason (21)
/opt/openoffice4/program/uno.py:92 in function fileUrlToSystemPath() [return pyuno.fileUrlToSystemPath( url )]
vnd.sun.star.tdoc:/1/Scripts/python/tasks.py:19 in function <module>() [None]
/opt/openoffice4/program/pythonscript.py:450 in function getModuleByUrl() [exec(code, entry.module.__dict__)]
/opt/openoffice4/program/pythonscript.py:991 in function getScript() [mod=self.provCtx.getModuleByUrl( fileUri )]
Ich vermute, es liegt daran, wie ich die Scripte in den Pythonpfad einbinde:
Code: Alles auswählen
import uno
import sys
doc = XSCRIPTCONTEXT.getDocument()
pythonPath = uno.fileUrlToSystemPath(doc.URL) + '/Scripts/python'
if pythonPath not in sys.path: sys.path.append(pythonPath)
Das funktioniert wohl nicht, weil die Datei noch nicht gespeichert ist. Welche Lösung wäre richtig? Im Internet habe ich nichts gefunden.
Schöne Grüße
Volker
Beim Erstellen eines neuen Dokuments aus einer Dokumentvorlage soll ein Makro starten, das in der Dokumentvorlage liegt.
Das Dokument erscheint wie gewünscht als 'Unbenannt 1', allerdings mit folgender Fehlermeldung:
[quote]Meldung: <class 'uno.com.sun.star.uno.RuntimeException'>: Couldn't convert file url to a system path for reason (21)
/opt/openoffice4/program/uno.py:92 in function fileUrlToSystemPath() [return pyuno.fileUrlToSystemPath( url )]
vnd.sun.star.tdoc:/1/Scripts/python/tasks.py:19 in function <module>() [None]
/opt/openoffice4/program/pythonscript.py:450 in function getModuleByUrl() [exec(code, entry.module.__dict__)]
/opt/openoffice4/program/pythonscript.py:991 in function getScript() [mod=self.provCtx.getModuleByUrl( fileUri )][/quote]
Ich vermute, es liegt daran, wie ich die Scripte in den Pythonpfad einbinde:
[code]import uno
import sys
doc = XSCRIPTCONTEXT.getDocument()
pythonPath = uno.fileUrlToSystemPath(doc.URL) + '/Scripts/python'
if pythonPath not in sys.path: sys.path.append(pythonPath)
[/code]
Das funktioniert wohl nicht, weil die Datei noch nicht gespeichert ist. Welche Lösung wäre richtig? Im Internet habe ich nichts gefunden.
Schöne Grüße
Volker