Writer Guide

Chapter 10
Working with TemplatesCopyrightThis document is Copyright © 2011 by its contributors as listed below. You may distribute it and/or
modify it under the terms of either the GNU General Public License(http://www.gnu.org/licenses/gpl.html), version 3 or later, or the Creative Commons Attribution
License (http://creativecommons.org/licenses/by/3.0/), version 3.0 or later.
All trademarks within this guide belong to their legitimate owners.

Contributors
Jean Hollis Weber
Ron Faile Jr.
Barbara Duprey
Hazel Russman
Gary Schnabl

Feedback
Please direct any comments or suggestions about this document to:
documentation@global.libreoffice.org

Acknowledgments
This chapter is based on Chapter 10 of the OpenOffice.org 3.3 Writer Guide. The contributors tothat chapter are:Alan MaddenJean Hollis Weber

Paul Miller
Michele Zarri

Catherine Waterman

Publication date and software version
Published 29 November 2011. Based on LibreOffice 3.4.4.

Note for Mac users
Some keystrokes and menu items are different on a Mac from those used in Windows and Linux.
The table below gives some common substitutions for the instructions in this chapter. For a moredetailed list, see the application Help.
Windows or LinuxMac equivalent

EffectTools > Options menu
selection

LibreOffice > Preferences

Access setup options

Right-click

Control+click

Opens context menu

Ctrl Control)z (Command)

Used with other keys

F5

Shift+z+F5

Opens the Navigator

F11

z+T

Opens Styles and Formatting window

Documentation for LibreOffice is available at www.libreoffice.org

Contents
Copyright......................................................................................................................................... 2
Note for Mac users........................................................................................................................... 2
Introduction...................................................................................................................................... 4
Using a template to create a document............................................................................................ 4
Creating a template.......................................................................................................................... 5
Creating a template from a document..........................................................................................5
Creating a template using a wizard............................................................................................. 6
Editing a template............................................................................................................................ 6
Updating a document from a changed template.......................................................................... 7
Adding templates obtained from other sources................................................................................ 8
Installing individual templates...................................................................................................... 8
Installing collections of templates................................................................................................ 8
Setting a default template................................................................................................................ 9
Setting a custom template as the default..................................................................................... 9
Resetting Writer’s default template as the default......................................................................10
Associating a document with a different template.......................................................................... 10
Organizing templates..................................................................................................................... 11Creating a template folder.......................................................................................................... 11
Deleting a template folder.......................................................................................................... 11
Moving a template..................................................................................................................... 11
Deleting a template.................................................................................................................... 12
Importing a template.................................................................................................................. 12
Exporting a template.................................................................................................................. 12
Printing a list of styles defined in a template or document.............................................................. 12

Working with Templates

3Introduction
A template is a model that you use to create other documents. For example, you can create a
template for business reports that has your company’s logo on the first page. New documents
created from this template will all have your company’s logo on the first page.
Templates can contain anything that regular documents can contain, such as text, graphics, a setof styles, and user-specific setup information such as measurement units, language, the default
printer, and toolbar and menu customization.
All documents in LibreOffice are based on templates. If you do not specify a template when you
start a new Writer document, then the document is based on the default template for text
documents. If you have not specified a default template, Writer uses the blank template for text
documents that is installed with LibreOffice. See “Setting a default template” on page 8 for more
information.

Using a template to create a document
To use a template to create a document:
1) From the menu bar, choose File > New > Templates and Documents to open the
Templates and Documents dialog box.

Figure 1. Templates and Documents dialog box2) In the box on the left, click the Templates icon if it is not already selected. A list of template
folders appears in the center box.
3) Double-click the folder that contains the template that you want to use. A list of all thetemplates contained in that folder appears in the center box (as shown in Figure 1).
4) Select the template that you want to use. You can either preview the selected template orview its properties:•

4

To preview the template, click the Preview icon
appears in the box on the right.

. A preview of the template

Working with Templates•

To view the template’s properties, click the Document Properties icon
template’s properties appear in the box on the right.

. The5) Click Open. The Templates and Documents dialog box closes and a new document basedon the selected template opens in Writer. You can then edit and save the new document
just as you would any other document.

Creating a template
You can create your own templates in two ways: from a document or using a wizard.

Creating a template from a document
To create a template from a document:
1) Open a new or existing document that you want to make into a template.
2) Add the content and styles that you want.
3) From the menu bar, choose File > Templates > Save to open the Templates dialog box(see Figure 2).
4) In the New template field, type a name for the new template.
5) In the Categories list, select the category to which you want to assign the template. The
category is simply the template folder in which you want to save the template. Choosing anappropriate category makes it easier to find the template when you want to use it. For
example, to save the template in the My Templates folder, click the My Templates
category. If you have a lot of templates, you might want to set up separate folders fordifferent projects or purposes.
To learn more about template folders, see “Organizing templates” on page 11.
6) Click OK to save the new template.

Figure 2. Saving a new template
Any settings that can be added to or modified in a document can be saved in a template. For
example, below are some of the settings (although not a full list) that can be included in a Writer
document and then saved as a template for later use:

• Printer settings: which printer, single-sided or double-sided printing, paper size, and so on• Styles to be used, including character, page, frame, numbering, and paragraph styles• Format and settings regarding indexes, tables, bibliographies, table of contents
Creating a template5Templates can also contain predefined text, saving you from having to type it every time you create
a new document. For example, a letter template may contain your name, address, and salutation.
You can also save menu and toolbar customizations in templates; see Chapter 16, Customizing
Writer, for more information.

Creating a template using a wizard
You can use wizards to create Writer templates for letters, faxes, and agendas.
For example, the Fax Wizard guides you through the following choices:• Type of fax (business or personal)• Document elements like the date, subject line (business fax), salutation, andcomplimentary close• Options for sender and recipient information (business fax)
• Text to include in the footer (business fax)
To create a template using a wizard:
1) From the menu bar, choose File > Wizards > [type of template required].

Figure 3: Creating a template using a wizard
2) Follow the instructions on the pages of the wizard. This process is slightly different for eachtype of template, but the format is similar for all of them.
3) In the last section of the wizard, you can specify the name and location for saving thetemplate. The default location is your user templates directory, but you can choose a
different location if you prefer.
4) Finally, you have the option of creating a new document from your template immediately, or
manually changing the template. For future documents, you can re-use the template
created by the wizard, just as you would use any other template.

Editing a template
You can edit a template’s styles and content, and then, if you wish, you can reapply the template’s
styles to documents that were created earlier from that template. Note that this only applies tostyles. If you change the content of a template, other than headers and footers, the change cannot
be applied retrospectively to existing documents.

6

Working with TemplatesTo edit a template:1) From the menu bar, choose File > Templates > Edit to open a standard file browser
window.
2) Select and open the template that you want to edit.
3) Edit the template just as you would any other document. To save your changes, choose
File > Save from the menu bar.

Updating a document from a changed template
The next time you open a document that was created from the changed template, the following
message appears.

Figure 4. Update styles message
Click Update Styles to apply the template’s changed styles to the document. Click Keep Old
Styles if you do not want to apply the template’s changed styles to the document (but see the
Caution notice below).
If you choose Keep Old Styles in the message box shown in Figure 4, that message
will not appear again the next time you open the document after changing thetemplate it is based on. You will not get another chance to update the styles from thetemplate, although you can use the macro given in the Note below to re-enable thisfeature.

CautionYou can also use the Template Changer extension (see page 10) to reactivate thetemplate.

To re-enable updating from a template:1) Use Tools > Macros > Organize Macros > LibreOffice Basic. Select the
document from the list, click the expansion symbol (+ or triangle), and selectStandard. If Standard has an expansion symbol beside it, click that and select a
module.
2) If the Edit button is active, click it. If the Edit button is not active, click New.
3) In the Basic window, enter the following:

Sub FixDocV3' set UpdateFromTemplate
oDocSettings = ThisComponent.createInstance( _"com.sun.star.document.Settings" )oDocSettings.UpdateFromTemplate = True
End Sub 'FixDocV3

Note4) Click the Run BASIC icon, then close the Basic window.
5) Save the document.

Next time when you open this document you will have the update from templatefeature back.

Editing a template7Adding templates obtained from other sources
You can download templates for LibreOffice from many sources, including the official template
repository at http://templates.libreoffice.org/, and install them on your computer. On other websites
you may find collections of templates that have been packaged into extension (.OXT) files. These
are installed a bit differently, as described below.

Installing individual templates
To install individual templates:
1) Download the template and save it anywhere on your computer.
2) Import the template into a template folder by following the instructions in “Importing atemplate“ on page 12.

Tip(For advanced users) If you know the location of LibreOffice template folders, you
can manually copy new templates into them. The location varies with yourcomputer’s operating system. To learn where the template folders are stored onyour computer, go to Tools > Options > LibreOffice > Paths.

Installing collections of templates
The Extension Manager provides an easy way to install collections of templates that have been
packaged as extensions. Follow these steps:
1) Download the extension package (.OXT file) and save it anywhere on your computer.
2) In Writer, select Tools > Extension Manager from the menu bar. In the Extension Manager
dialog box (Figure 5), click Add to open a file browser window.

Figure 5: Newly-added package of templates
3) Find and select the package of templates you want to install and click Open. The package
begins installing. You may be asked to accept a license agreement.

8

Working with Templates4) When the package installation is complete, the templates are available for use through File
> New > Templates and Documents and the extension is listed in the Extension Manager.
See Chapter 16, Customizing Writer, for more about the Extension Manager.

Setting a default template
If you create a document by choosing File > New > Text Document from the menu bar, Writercreates the document from the default template for text documents. You can, however, set acustom template to be the default. You can reset the default later, if you choose.

Note forWindowsusers

You may know that Microsoft Word employs a normal.docm file for its default
template and how to regenerate it.
LibreOffice does not have a similar default template file; the “factory defaults” areembedded within the software.

Setting a custom template as the default
You can set any template to be the default, as long as it is in one of the folders displayed in the
Template Management window. If necessary, you can add the template to a folder as described in“Importing a template” on page 12.
To set a custom template as the default:
1) From the menu bar, choose File > Templates > Organize to open the Template
Management dialog box.
2) In the box on the left, select the folder that contains the template that you want to set as thedefault, then select that template.
3) Click the Commands button and choose Set As Default Template from the drop-down
menu.

Figure 6: Setting a default template using the Template Management dialog box

Setting a default template

9The next time that you create a document by choosing File > New > Text Document, thedocument will be created from this template.
Although many important settings can be changed in the Options dialog box (see Chapter 2,
Setting up Writer), for example default fonts and page size, more advanced settings (such as pagemargins) can only be changed by replacing the default template with a new one.

Resetting Writer’s default template as the default
To re-enable Writer’s default template as the default:
1) In the Template Management dialog box (Figure 6), select any folder in the box on the left.
2) Click the Commands button and choose Reset Default Template from the drop-downmenu. This command does not appear unless a custom template has previously been set
as the default, as described in the previous section.
The next time that you create a document by choosing File > New > Text Document, thedocument will be created from Writer’s default template.

Associating a document with a different template
At times you might want to associate a document with a different template, or perhaps you’re
working with a document that did not start from a template.
One of the major advantages of using templates is the ease of updating styles in more than one
document, as described in Chapter 7, Working with Styles. If you update styles by loading a new
set of styles from a different template (as described in Chapter 7), the document has no
association with the template from which the styles were loaded—so you cannot use this method.
What you need to do is associate the document with the different template.
You can do this in two ways. For best results in both cases, the names of styles should be thesame in the existing document and the new template. If they are not, you will need to use Edit >Find & Replace to replace old styles with new ones. See Chapter 3, Working with Text, for more
about replacing styles using Find & Replace.
Method 1
This method includes any graphics and wording (such as legal notices) that exist in the newtemplate, as well as including styles. If you don’t want this material, you need to delete it.
1) Use File > New > Templates and Documents. Choose the template you want. A new fileis created from the template. If the template has unwanted text or graphics in it, deletethem from this new file.
2) Open the document you want to change. (It opens in a new window.) Press Control+A toselect everything in the document. Paste into the blank document created in step 1.
3) Update the table of contents, if there is one. Save the file.
Method 2
This method does not include any graphics or text from the new template, except material inheaders and footers; it simply includes styles from the new template and establishes anassociation between the template and the document.
1) Open the document whose template you want to change. Choose File > Templates >Assign Template (current document).
2) In the Select Template window, find and select the required template and click Open.
3) Save the document. If you now look in File > Properties, you will see the new template
listed at the bottom of the General page.

10

Working with Templates

Note

If you do not see Assign Template (current document) or Assign Template(folder) under File > Templates, you need to download the Template Changer
extension from http://extensions-test.libreoffice.org/ and install it as described on
page 8. Then close and reopen LibreOffice to activate the extension.

Organizing templates
Writer can only use templates that are in LibreOffice template folders. You can, however, create
new LibreOffice template folders and use them to organize your templates. For example, you might
have one template folder for report templates and another for letter templates. You can also importand export templates.
To begin, choose File > Templates > Organize from the menu bar to open the Template
Management dialog box (Figure 6).

Note

All the actions in the Commands drop-down menu in the Template Management
dialog are accessible by right-clicking on a template or a folder.

Tip

The location of LibreOffice template folders varies with your computer’s operating
system. To learn where the template folders are stored on your computer, go toTools > Options > LibreOffice > Paths.

Creating a template folder
To create a template folder:1) In the Template Management dialog box, select any folder.
2) Click the Commands button and choose New from the drop-down menu. A new folder
called Untitled appears.
3) Type a name for the new folder, and then press Enter. Writer saves the folder with thename that you entered.

Deleting a template folder
As an ordinary user, you cannot delete template folders supplied with LibreOffice or installed using
the Extension Manager; you can only delete template folders that you have created. (If you haveadministrator privileges, you can delete any folder.)To delete a template folder:1) In the Template Management dialog box, select the folder that you want to delete.
2) Click the Commands button and choose Delete from the drop-down menu. A message box
appears, asking you to confirm the deletion. Click Yes.

Moving a template
To move a template from one template folder to another:
1) In the Template Management dialog box, double-click the folder that contains the templatethat you want to move. A list of all the templates contained in that folder appears
underneath the folder name.

Organizing templates112) Click the template that you want to move and drag it to the desired folder. If you do nothave the authority to delete templates from the source folder, this action copies the
template instead of moving it.

Deleting a template
As an ordinary user, you cannot delete templates supplied with LibreOffice or installed using the
Extension Manager; you can only delete templates that you have created. (If you haveadministrator privileges, you can delete any template.)
To delete a template:1) In the Template Management dialog box, double-click the folder that contains the templatethat you want to delete. A list of all the templates contained in that folder appears
underneath the folder name.
2) Click the template that you want to delete.
3) Click the Commands button and choose Delete from the drop-down menu. A message box
appears and asks you to confirm the deletion. Click Yes.

Importing a template
If the template that you want to use is in a different location, you must import it into a LibreOffice
template folder.
To import a template into a template folder:1) In the Template Management dialog box, select the folder into which you want to import the
template.
2) Click the Commands button and choose Import Template from the drop-down menu. A
standard file browser window opens.
3) Find and select the template that you want to import, and then click Open. The file browser
window closes and the template appears in the selected folder.
4) If you want, enter a new name for the template, and then press Enter.

Exporting a template
To export a template from a template folder to another location:1) In the Template Management dialog box, double-click the folder that contains the templatethat you want to export. A list of all the templates contained in that folder appears
underneath the folder name.
2) Select the template that you want to export.
3) Click the Commands button and choose Export Template from the drop-down menu to
open the Save As window.
4) Find the folder into which you want to export the template and click Save.

Printing a list of styles defined in a template or document
To print a list of the styles defined in a template:1) In the Template Management dialog, double-click the folder that contains the template.
2) Double-click the required template. Styles appears below it. Click Styles to select it.
3) Click the Commands button and choose Print from the drop-down menu. The Print dialog
opens. From here you can print to a file or to a printer as usual. For more about the Print
dialog, see Chapter 10.

12

Working with TemplatesFigure 7: Printing a list of styles in a template

Tip

To print a list of styles in a document, double-click on the document’s name in the
middle column to display Styles, and then use Commands > Print.

Printing a list of styles defined in a template or document13