Mathias Bauer wrote:
Giuseppe Castagno wrote:
Hi all,
I'm trying to use from API the templates delivered through
extension [1], using the English version.
According to 7.1.5 [2] of dev guide the MediaDescriptor properties
TemplateName and TemplateRegionName should be the ones to be used,
but the following chunk of macro code doesn't run:
Sub Macro1
dim args(4) as new com.sun.star.beans.PropertyValue
args(0).Name = "AsTemplate"
args(0).Value = True
args(1).Name = "TemplateName"
args(1).Value = "Book"
args(2).Name = "TemplateRegionName"
args(2).Value = "Miscellaneous"
args(3).Name = "MacroExecutionMode"
args(3).Value =
com.sun.star.document.MacroExecMode.ALWAYS_EXECUTE_NO_WARN
oGlobalDoc =
StarDesktop.loadComponentFromURL("private:factory/swriter", "_blank", 0,
args())
End Sub
It doesn't open a new document based on the requested template.
I'd like to use the api with templates the way the
"File > New > Template and Document" dialog works, but so far
with no luck.
Any idea?
It seems to fail for *every* template, not only for those added as
extensions. I think this is a bug. I couldn't find any code evaluating
the arguments "TemplateRegionName" and "TemplateName". I'm not sure if
there is an issue already, but it's possible.
issue 82287 [1] seems dealing with this same problem, may be it's
wrongly assigned?
The following code should work:
sub opentemplate
dim args(2) as new com.sun.star.beans.PropertyValue
args(0).Name = "Region"
args(0).Value = "Finances"
args(1).Name = "Name"
args(1).Value = "Car Costs"
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dispatcher.executeDispatch(StarDesktop, ".uno:NewDoc", "", 0,args())
End Sub
but it doesn't give you a return value. Perhaps this is enough for you?
It's enough, thank you.
I retrieve the document as ThisComponent immediately after the call, I
hope the call it's synchronous?
--
Kind Regards,
Giuseppe Castagno
Acca Esse http://www.acca-esse.eu
[EMAIL PROTECTED]
[1] http://www.openoffice.org/issues/show_bug.cgi?id=82287
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]