I made a Template with some macro's in OpenOffice Writer. For these macro's I need the TemplateURL. I write macros in Openoffice Basic.
When I start (for example) TemplateDossierNew.ott by double-clicking it (then it generates a new document named Untitled 1.odt, based on TemplateDossierNew.ott) but it doesn't allow me to get the TemplateURL. Because it doesn't know on which template the file is based? I don't know why.
When I open OpenOffice and then choose my TemplateDossierNew via the "Templates and Documents - My Templates"-dialog the generated file does allow me to use getTemplateURL.
I can open a OpenOffice file via Command Prompt by: C:\PathToSOffice\soffice.exe "C:\PathToFile\TemplateDossierNew.ott" When I open the file in this way it doesn't have any Template information just like the double-click way.
What I need: I want to open the OpenOffice Template from my Command Prompt. Important is that the new generated file (Untitled 1.odt) knows on which template it is based, so I can use getTemplateURL.
Thank you in advance!
When you add your template to OpenOffice in the Template Management the template will be put in ...\AppData\Roaming\OpenOffice\4\user\template.
If you use a command with the path to the Template that is in your AppData you can use getDocumentProperties and TemplateURL in your macro. It will refer to the location in your AppData.
Example to put in your command prompt:
swriter C:\Users\user\AppData\Roaming\OpenOffice\4\user\template\TemplateDossierNew.ott.
If you have this code in your macro: (and then execute the command above in your command prompt)
MsgBox "TemplateURL=" + ThisComponent.getDocumentProperties().TemplateURL
The output will be:
TemplateURL=file:///C:/Users/user/AppData/Roaming/OpenOffice/4/user/template/TeplateDossierNew.ott