Main Content

创建一个MicrosoftWordDocument Part Template Library

一个医生ument 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 DOMDocumentPartobjects.

  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 theInserttab, click theExplore Quick Partsbutton. SelectSave Selection to the Quick Parts Gallery.

  5. In the Create New Building Block dialog box, in theNamefield, enter a unique name for the template. Use this name in the constructor of aDocumentPartobject.

  6. For the first document part template you create in the template file, in theCategorylist, clickCreate New Category. Create a category namedmlreportgen. Then selectmlreportgenCategorylist.

    Otherwise, selectmlreportgenCategorylist.

  7. In the德scriptionfield, enter a template description and clickOK.

  8. 德lete 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 theInserttab, click theExplore Quick Partsbutton.

  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 theInserttab, clickExplore Quick Partsand selectSave 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 themlreportgencategory. Respond to the prompt to overwrite the previous version.

  8. 德lete the instance in the template document, and save and close the template.

Word文档列表部分限制

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 anOrderedListorUnorderedListobject 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