Main Content

Create a Microsoft Word Document Part Template Library

A document part template library is a set of document part templates stored by name in a template file. Document part template libraries allow you to store all the templates for a report in a single template file, for example, the main template file of a report. You can create additional template files, each with a specific purpose, and create document part template libraries in them.

Using the DOM API, you can create an instance of a document part based on a template stored in a library by specifying the name of the template in the document part constructor. For form-based reports that you create using the Report Explorer, create an instance by specifying the template file and the name of the subform template from the document part template library.

Create Document Part Template Library in a Word Template

You can use the Quick Parts Gallery in Word to create a document part template library in the main template of a report. A Quick Part Gallery is a collection of reusable pieces of preformatted content, called quick parts, that are stored in the document. You can use quick parts as templates for DOM DocumentPart objects.

  1. Open the Word template in which you want to create the document part template.

  2. In the template, create the Word content to serve as a prototype for the document part template. (You delete the prototype after copying it to the Quick Part Gallery.) The document part template content that you create can contain holes and page layout sections, and other types of Word content. For example:

  3. Select the content that you have created for the document part template.

  4. On the Insert tab, click the Explore Quick Parts button. Select Save Selection to the Quick Parts Gallery.

  5. In the Create New Building Block dialog box, in the Name field, enter a unique name for the template. Use this name in the constructor of a DocumentPart object.

  6. For the first document part template you create in the template file, in the Category list, click Create New Category. Create a category named mlreportgen. Then select mlreportgen from the Category list.

    Otherwise, select mlreportgen from the Category list.

  7. In the Description field, enter a template description and click OK.

  8. Delete the content that served as the prototype for the document part template.

  9. Save the template file.

Modify Document Part Template in Quick Part Gallery

You can modify a document part template stored in the Quick Part Gallery.

  1. Open the Word template that contains the document part template.

  2. Click in the template where you want to create an instance of the document part template.

  3. On the Insert tab, click the Explore Quick Parts button.

  4. In the Quick Part Gallery, to create an instance, select the document part template you want to modify.

  5. Edit the instance.

  6. Select the modified instance. On the Insert tab, click Explore Quick Parts and select Save Selection to the Quick Part Gallery.

  7. In the Create New Building Block dialog box, enter the name of the document part template you modified and select the mlreportgen category. Respond to the prompt to overwrite the previous version.

  8. Delete the instance in the template document, and save and close the template.

Word Document Part List Limitations

The DOM API does not support use of lists in the fixed content of a document part template. Such lists can appear with incorrect formatting in the output document. To include a list in a document part, generate the list programmatically, that is, append an OrderedList or UnorderedList object to the part where you want the list to appear. If you want to apply a style to the list, you must use a list style defined in your main document.

See Also

Classes

Related Examples

More About