Creating and editing a template

From Apache OpenOffice Wiki
Jump to: navigation, search

Creating a template

You can create a template from a document:

  1. Open a new or existing document of the type you want to make into a template (text document, spreadsheet, drawing, presentation).
  2. Add the content and styles that you want.
  3. From the main menu, choose File > Templates > Save. The Templates dialog opens.
  4. In the New template field, type a name for the new template.
  5. In the Categories list, click the category to which you want to assign the template. The category you choose has no effect on the template itself; it is simply the folder in which you save the template. Choosing an appropriate folder (category) makes it easier to find the template when you want to use it. You may wish to create a folder for Calc templates. To learn more about template folders, see Organizing templates.
  6. Click OK to save the new template.
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 Calc document and then saved as a template for later use:

  • Printer settings: which printer, single sided / double sided, and paper size, and so on
  • Cell and page styles to be used

Templates can also contain predefined text, saving you from having to type it every time you create a new document. For example, an invoice template might contain your company’s name, address and logo.

You can also save menu and toolbar customizations in templates; see Setting up and Customizing Calc for more information.

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 from that template. (Note that you can only reapply styles. You cannot reapply content.)

To edit a template:

  1. From the main menu, choose File > Templates > Organize. The Template Management dialog opens.
  2. In the box on the left, double-click the folder that contains the template that you want to edit. A list of all the templates contained in that folder appears underneath the folder name.
  3. Select the template that you want to edit.
  4. Click the Commands button and choose Edit from the drop-down menu.
  5. Edit the template just as you would any other document. To save your changes, choose File > Save from the main menu.
Template management dialog.

Updating a spreadsheet from a changed template

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

Apply current styles message.

Click Update Styles to apply the template’s changed styles to the spreadsheet. Click Keep Old Styles if you do not want to apply the template’s changed styles to the spreadsheet (but see Caution notice below).

Documentation caution.png If you choose Keep Old Styles in the message box shown above, that message will not appear again the next time you open the document after changing the template it is based on. You will not get another chance to update the styles from the template, although you can use the macro given in the Note below to re-enable this feature.
Documentation note.png To re-enable updating from a template:
  1. Use Tools > Macros > Organize Macros > Basic. Select the document from the list, click the +, and select Standard. If Standard has a + beside it, click that and select a module.
  2. Name the macro. For example, you could call it FixDocument. If the Edit button is active, click it. If the Edit button is not active, click New, type a module name in the pop-up dialog, and click OK.
  3. In the Basic window, enter the following:
  4.  Sub FixDocument 
     ' set UpdateFromTemplate 
      oDocSettings = ThisComponent.createInstance( "" ) 
      oDocSettings.UpdateFromTemplate = True 
     End Sub 'FixDocument
  5. Click the Run BASIC icon, then close the Basic window.
  6. Save the document.

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

Content on this page is licensed under the Creative Common Attribution 3.0 license (CC-BY).
Personal tools