Python: Problem: Neu aus Dokumentvorlage
Verfasst: Di, 19.01.2016 14:06
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:
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
Das Dokument erscheint wie gewünscht als 'Unbenannt 1', allerdings mit folgender Fehlermeldung:
Ich vermute, es liegt daran, wie ich die Scripte in den Pythonpfad einbinde: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 )]
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)
Schöne Grüße
Volker