Mavention Blog > April 2009

Deploy custom templates in Office 2007

If you work a lot with the office suite. You'll probably have your own templates for all kinds of word documents, excel workbooks, etc. Everytime you need a new document you start by making a copy of an other document and first clear all text.

Wouldn't it be nice if you had all your templates right on the 'select new template' page in Word or other office products like the picture below.



With the office 2007 suite it is very easy to add your own templates.

First you copy all your templates to a directory that will hold all templates e.g. c:\templates.
Second you create an xml file like the one below:
<?xmlversion="1.0"encoding="utf-8"?>
<o:featuredcontentlcid="1033"xmlns:o="urn:schemas-microsoft-com:office:office">
<o:applicationid="WD">
 
<o:featuredtemplatesstartdate="2007-01-01"enddate="2014-01-01">
 
<!-- TEMPLATE 1 -->
<o:featuredtemplatetitle="Briefpapier"source="C:\Users\Administrator\Documents\Mavention\Templates\Briefpapier_template.dotx" >
<o:mediamediatype="jpg"filename="MaventionLogo.jpg"source="" />
<o:previewfilename="MaventionLogo.jpg"source="" />
</o:featuredtemplate>
 
<!-- TEMPLATE 2 -->
<o:featuredtemplatetitle="CV"source="C:\Users\Administrator\Documents\Mavention\Templates\Curriculum_Vitae_template.dotx" >
<o:mediamediatype="jpg"filename="MaventionLogo.jpg"source="" />
<o:previewfilename="MaventionLogo.jpg"source="" />
</o:featuredtemplate>
 
<!-- TEMPLATE 3 -->
<o:featuredtemplatetitle="Offertedocument"source="C:\Users\Administrator\Documents\Mavention\Templates\Offerte_template.dotx" >
<o:mediamediatype="jpg"filename="MaventionLogo.jpg"source="" />
<o:previewfilename="MaventionLogo.jpg"source="" />
</o:featuredtemplate>
 
<!-- TEMPLATE 4 -->
<o:featuredtemplatetitle="Ontwerpdocument"source="C:\Users\Administrator\Documents\Mavention\Templates\Ontwerpdocument_template.dotx" >
<o:mediamediatype="jpg"filename="MaventionLogo.jpg"source="" />
<o:previewfilename="MaventionLogo.jpg"source="" />
</o:featuredtemplate>
</o:featuredtemplates>
</o:application>
</o:featuredcontent>
 
In this sample you see that the line <o:applicationid="WD"> contains “WD” as value for the id attribute. This means that the next featuretemplate elements are used in Word. You can also define the values “XL” for Excel templates and “PP” for PowerPoint templates.
 
The featuretemplate element allows you to define the title as it will appear in the ‘select a new template’ page. The source attribute is used for locating the template file (e.g. the ones you copied to the c:\templates directory).
The elements media and preview can be used for adding a previewimage for the template.

Now that the XML file contains proper values for all elements there’s just one thing that needs to be done. Adding a key to the Windows Registry.
I’ve created a installOfficeTemplates.reg file that contains the following information:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\Spotlight\Providers\Mavention ]
"ServiceURL"="C:\\Users\\Administrator\\Documents\\Mavention\\Templates\\Mavention.xml"

As you notice, this .reg file installs a new key with its value pointing to the xml file we just created. If you run this file or create this key manually, you can use all template files that are in the xml file in your Office products.
Ciao,
Niels
Posted: 13-4-2009 13:27:01 by Niels Loup | with 0 comments
Filed under: office, registry, templates, windows, xml, 2007


Commentaren
Blogbericht heeft op dit moment nog geen commentaren.
Laat commentaar achter



 Security code