Tam <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]:

> I thought this would be simple -- it isn't.  I just want to have a 
> macro create a new document from a template (not the default template).
> 

You want this --
Function NewFromTemplate(templateURL)
' acb June 2002
' pass this function the fully qualified path of the template 
' you want to use, eg
' NewFromTemplate
("file:///D:/OpenOffice.org.1.0/user/template/mytemplate.stw")
' this is useful as a way to make menu entries or buttons
' which open a particular template with one click.
Dim MyDoc,TC As Object
Dim mFileProperties(0) As New com.sun.star.beans.PropertyValue
mFileProperties(0).Name="AsTemplate"
mFileProperties(0).Value=true
oDesktop = createUnoService("com.sun.star.frame.Desktop")
sUrl =templateURL
MyDoc=oDesktop.loadComponentFromURL(sUrl,"_blank",0,mFileProperties())
TC=MyDoc.currentcontroller.getViewCursor()
TC.gotoend(FALSE)
end Function

called from something like this

Sub NewLetter
NewFromTemplate("file:///D:/oo%20users/common%20templates/william%
20morris%20letter.stw")
End Sub

Except you change the file:/// url to point at your real template. The 
reason for splitting thi sinto a funcitno and a sub is so that you can 
easily and quickly write NewLetter, NewInvoice, NewLoveLetter etc macros 
for any template you make.

All this and more from my sig file.


-- 
Andrew Brown
The email in the header does not work.
Contact details and possibly useful macros from
http://www.darwinwars.com/lunatic/bugs/oo_macros.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to