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.
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?
Ciao,
Mathias
--
Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
Please don't reply to "[EMAIL PROTECTED]".
I use it for the OOo lists and only rarely read other mails sent to it.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]